From febce03328a75e5db686d40ec39bde99424c0956 Mon Sep 17 00:00:00 2001 From: Daniel Hladek Date: Sat, 3 Oct 2020 11:13:23 +0200 Subject: [PATCH] dont display zero length popular and latest --- themes/mytheme/templates/partials/sidebar.html.twig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/themes/mytheme/templates/partials/sidebar.html.twig b/themes/mytheme/templates/partials/sidebar.html.twig index 15466c62..7ca0aedf 100644 --- a/themes/mytheme/templates/partials/sidebar.html.twig +++ b/themes/mytheme/templates/partials/sidebar.html.twig @@ -82,14 +82,15 @@ {% endif %} {% endfor %} {% set popular = tmplst %} + {% if popular|length > 0 %}

{{ 'POPULAR_ARTICLES'|t }}

{% include 'partials/topiclist.html.twig' with {'articles': popular, 'maxcount': maxcount} %} + {% endif %} {% endif %} {% if grav.theme.config.params.sidebar.show.latest %}
-

{{ 'LATEST_ARTICLES'|t }}

{% set tmplst = [] %} {% for page in my_collection %} {% set blisted = false %} @@ -104,6 +105,9 @@ {% endif %} {% endfor %} {% set articles = tmplst|slice(0,maxcount) %} - {% include 'partials/topiclist.html.twig' with {'articles': articles, 'maxcount': maxcount} %} + {% if articles|length > 0 %} +

{{ 'LATEST_ARTICLES'|t }}

+ {% include 'partials/topiclist.html.twig' with {'articles': articles, 'maxcount': maxcount} %} + {% endif %}
{% endif %}