grav/themes/quark/templates/partials/taxonomylist.html.twig

41 lines
1.3 KiB
Twig

{% if "events" in page.url %}
{% set pages = page.collection() %}
{% set taxonomy_count = {} %}
{% for p in pages %}
{% for taxonomy, values in p.taxonomy %}
{% for value in values %}
{% if value in taxonomy_count %}
{% 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 %}
<ul>
{% for taxonomy, count in most_common_taxonomies %}
<li>{{ taxonomy }} ({{ count }} occurrences)</li>
{% endfor %}
</ul>
{% else %}
{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags() : taxonomylist.get() %}
{% endif %}
{% if taxlist %}
<span class="tags">
{% for tax,value in taxlist[taxonomy] %}
{% set label_class = uri.param(taxonomy) == tax ? 'label-primary' : 'label-secondary' %}
<a class="label label-rounded {{ label_class }}" href="{{ base_url }}/{{ taxonomy }}{{ config.system.param_sep }}{{ tax }}">{{ tax }}</a>
{% endfor %}
</span>
{% endif %}