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

41 lines
1.1 KiB
Twig
Raw Normal View History

2023-01-10 20:14:28 +01:00
{% if "events" in page.url %}
2023-01-10 21:28:33 +01:00
{% set pages = page.collection() %}
2023-01-10 21:36:57 +01:00
{% set tag_count = {} %}
2023-01-10 21:28:33 +01:00
{% for p in pages %}
2023-01-10 21:36:57 +01:00
{% 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 %}
2023-01-10 21:28:33 +01:00
{% endfor %}
{% endfor %}
2023-01-10 21:36:57 +01:00
{% set most_common_tags = tag_count|sort(sort_flags.SORT_REGULAR)|reverse %}
2023-01-10 21:40:26 +01:00
{{ most_common_tags }}
2023-01-10 21:28:33 +01:00
2023-01-10 21:32:38 +01:00
2023-01-10 21:35:31 +01:00
<ul>
2023-01-10 21:39:28 +01:00
{% for tag, count in most_common_tags %}
<li>{{ tag }} ({{ count }} occurrences)</li>
2023-01-10 21:35:31 +01:00
{% endfor %}
</ul>
2023-01-10 21:39:28 +01:00
2023-01-10 20:03:24 +01:00
{% else %}
2023-01-10 20:38:30 +01:00
{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags() : taxonomylist.get() %}
2023-01-10 20:03:24 +01:00
{% endif %}
2023-01-10 20:13:33 +01:00
{% 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 %}