3

I've got a blog section on a page but want to hide it if there are no blogs.

{% set blog = craft.entries.section('blog').limit(5) %}
{% if blog !='' %}
  <div class="something">
    {% for entry in blog %}
      ...
    {% endfor %}
  </div>
{% endif %}
6

Your blog variable is an ElementCriteriaModel, which can be treated like an iterable array:

{% if blog|length %}
    Content
{% endif %}
0

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.