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 %}

1 Answer 1

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 %}
1
  • Yep that did it! I just had to change that endif to an endfor for the looping content. Thanks a bunch!
    – kingkelly
    Commented Oct 12, 2017 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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