diff --git a/themes/quark/templates/partials/taxonomylist.html.twig b/themes/quark/templates/partials/taxonomylist.html.twig index 5aeb919e..73540521 100644 --- a/themes/quark/templates/partials/taxonomylist.html.twig +++ b/themes/quark/templates/partials/taxonomylist.html.twig @@ -1,5 +1,25 @@ {% if "events" in page.url %} - {% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags().where('event.start', 'exists') : taxonomylist.get().where('event.start', 'exists') %} + + + {% set pages = page.collection() %} + {% set taxonomy_count = {} %} + + {% for p in pages %} + {% for taxonomy in p.taxonomy %} + {% for value in p.taxonomy[taxonomy] %} + {% if taxonomy_count[value] is defined %} + {% set taxonomy_count = taxonomy_count|merge({ (value): taxonomy_count[value] + 1 }) %} + {% else %} + {% set taxonomy_count = taxonomy_count|merge({ (value): 1 }) %} + {% endif %} + {% endfor %} + {% endfor %} + {% endfor %} + + {% set most_common_taxonomies = taxonomy_count|sort(sort_flags.SORT_REGULAR)|reverse %} + + + {% set taxlist = most_common_taxonomies %} {% else %} {% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags() : taxonomylist.get() %} {% endif %}