Last active
March 22, 2024 23:26
-
-
Save tboulogne/25cbb91c2f15a75baefd961934326520 to your computer and use it in GitHub Desktop.
Grav template for automagic list of taxonomies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% embed 'partials/base.html.twig' %} | |
{% block content %} | |
{% set taxname = uri.query|split('=')[0] %} | |
{% set taxval = uri.query|split('=')[1]|replace({'+':" "}) %} | |
{% if taxname %} | |
{% set c = breadcrumbs.get() %} | |
{% set crumbs = c |merge([{'menu':taxname|pluralize|humanize,'url':"/taxonomy?#{taxname}",'routable':true}]) %} | |
{% if taxval %} | |
{% set crumbs = crumbs |merge([{'menu':taxval|humanize,'url':'/taxonomy','routable':false}]) %} | |
{% endif%} | |
{% endif %} | |
{% if config.plugins.breadcrumbs.enabled %} | |
{% include 'partials/breadcrumbs.html.twig' with {'crumbs':crumbs} %} | |
{% endif %} | |
<div class="blog-content-item grid pure-g-r"> | |
{{ page.content }} | |
</div> | |
<div class="content-wrapper blog-content-list grid pure-g"> | |
<div id="listing" class="block pure-u-2-3 h-feed"> | |
{% if taxname %} | |
{% if taxval %} | |
<section class="topiclist"> | |
<!-- taxonomy.findTaxonomy({(taxname): taxval}) --> | |
{% set collection = taxonomy.findTaxonomy({(taxname): taxval}) %} | |
{% include 'partials/item-cards.html.twig' with {'collection': collection,'params':[{'name':taxname, 'val': taxval}]} %} | |
</section> | |
{% else %} | |
<section> | |
<ul class='item-topics topics'> | |
{% for cat in taxonomy.taxonomy[taxname]|keys|sort %} | |
<a class="item-topic topic" href="{{ base_url }}/taxonomy?{{taxname}}={{taxval}}{{ cat | url_encode }}"><li class="{{ taxname }}">{{ cat|humanize }}</li></a> | |
{% endfor %} | |
</ul> | |
</section> | |
{% endif %} | |
{% else %} | |
<section> | |
<ul class="item-topics topics"> | |
{% for key in taxonomy.taxonomy|keys %} | |
{% if key not in ['archives_month','archives_year','category','categorie'] %} | |
<a class="item-topic topic" href="{{ page.url }}?{{key}}"> | |
<li class="{{ key }}" >{{key|capitalize|pluralize}}</li> | |
</a> | |
{% endif %} | |
{% endfor%} | |
</ul> | |
</section> | |
{% endif %} | |
</div> | |
</div> | |
{% endblock %} | |
{% endembed %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment