1

I'm having a bit of trouble showing a message if there's no entries in my blog. I tried the length filter but my empty message wont show:

{% for entry in craft.entries.section('volunteerPosition').find() %}
  {% if entry.volunteerPosition|length %}

      {{entry.volunteerShortDescription}}

  {% else %}

      Sorry, Nothing to show.

  {% endif %}
{% endfor %}
2

This should do it:

{# Get all of the entries in the 'volunteerPosition' section #}
{% set entries = craft.entries.section('volunteerPosition').find() %}

{# Do we have any %}
{% if entries|length %}

    {# Loop through them #}
    <ul>
        {% for entry in entries %}
            <li>{{ entry.volunteerShortDescription }}
        {% endfor %}
    </ul>

{% else %}
    {# Nothing to see here #}
    Sorry, nothing to show.
{% endif %}
| improve this answer | |
  • Yep that did it! I just had to change that endif to an endfor for the looping content. Thanks a bunch! – kingkelly Oct 12 '17 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.