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

40 lines
1.1 KiB
Twig

{% if "events" in page.url %}
{% set pages = page.collection() %}
{% set tag_count = {} %}
{% for p in pages %}
{% for tag in p.taxonomy.tags %}
{% if tag in tag_count %}
{% set tag_count = tag_count|merge({ (tag): tag_count[tag] + 1 }) %}
{% else %}
{% set tag_count = tag_count|merge({ (tag): 1 }) %}
{% endif %}
{% endfor %}
{% endfor %}
{% set most_common_tags = tag_count|sort(sort_flags.SORT_REGULAR)|reverse %}
<ul>
{% for taxonomy, count in most_common_tags %}
<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 %}