dmytro_ushatenko/themes/knowledge-base/templates/front.html.twig

50 lines
1.3 KiB
Twig

{% extends 'partials/base.html.twig' %}
{% block content %}
{% set catlist = taxonomy.taxonomy["category"]|keys %}
{% if grav.theme.config.params.articles.blacklist is defined %}
{% set blist = grav.theme.config.params.articles.blacklist %}
{% set tmplst = [] %}
{% for cat in catlist %}
{% if cat not in blist %}
{% set tmplst = tmplst|merge([cat]) %}
{% endif %}
{% endfor %}
{% set catlist = tmplst %}
{% endif %}
{% set rows=[] %}
{% set node=[] %}
{% set maxrows = 3 %}
{% if grav.theme.config.params.front.maxrows is defined %}
{% set maxrows = grav.theme.config.params.front.maxrows %}
{% endif %}
{% for cat in catlist|sort|slice(0,maxrows*2) %}
{% set node = node|merge([cat]) %}
{% if (node|length == 2) or (loop.last) %}
{% set rows = rows|merge([node]) %}
{% set node = [] %}
{% endif %}
{% endfor %}
{% set maxcount = 5 %}
{% if grav.theme.config.params.front.maxentries is defined %}
{% set maxcount = grav.theme.config.params.front.maxentries %}
{% endif %}
<section id="articlelist">
<div class="pure-g">
<div class="pure-u-1">
<h1>{{ 'ARTICLE_CATEGORIES'|t }}</h1>
</div>
{% for row in rows %}
{% for cat in row %}
<div class="pure-u-1 pure-u-md-1-2 frontrow">
{% include 'partials/frontlist.html.twig' with {'category': cat, 'maxcount': maxcount} %}
</div>
{% endfor %}
{% endfor %}
</div>
</section>
{% endblock %}