dont display zero length popular and latest

This commit is contained in:
Daniel Hladek 2020-10-03 11:13:23 +02:00
parent 7b4a270078
commit febce03328

View File

@ -82,14 +82,15 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% set popular = tmplst %} {% set popular = tmplst %}
{% if popular|length > 0 %}
<h1><span>{{ 'POPULAR_ARTICLES'|t }}</span></h1> <h1><span>{{ 'POPULAR_ARTICLES'|t }}</span></h1>
{% include 'partials/topiclist.html.twig' with {'articles': popular, 'maxcount': maxcount} %} {% include 'partials/topiclist.html.twig' with {'articles': popular, 'maxcount': maxcount} %}
{% endif %}
</div> </div>
{% endif %} {% endif %}
{% if grav.theme.config.params.sidebar.show.latest %} {% if grav.theme.config.params.sidebar.show.latest %}
<div class="topiclist"> <div class="topiclist">
<h1><span>{{ 'LATEST_ARTICLES'|t }}</span></h1>
{% set tmplst = [] %} {% set tmplst = [] %}
{% for page in my_collection %} {% for page in my_collection %}
{% set blisted = false %} {% set blisted = false %}
@ -104,6 +105,9 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% set articles = tmplst|slice(0,maxcount) %} {% set articles = tmplst|slice(0,maxcount) %}
{% if articles|length > 0 %}
<h1><span>{{ 'LATEST_ARTICLES'|t }}</span></h1>
{% include 'partials/topiclist.html.twig' with {'articles': articles, 'maxcount': maxcount} %} {% include 'partials/topiclist.html.twig' with {'articles': articles, 'maxcount': maxcount} %}
{% endif %}
</div> </div>
{% endif %} {% endif %}