Created
October 1, 2015 12:24
-
-
Save sbonardt/6db682d9841e6d4bd546 to your computer and use it in GitHub Desktop.
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
{# for Bolt.cm | |
Situation: A chapter contains an undefined amount of items, either with typefield "A" or with typefield "B" | |
(two "levels"). Print these items out in a hierarchical menu with nested ul's (2 levels deep as per "A" and "B" | |
If you need more levels, add -for instance- "C" and add extra checks in the code | |
Goal: | |
Go through the list of items in any chapter and print out hierarchical nested UL's based on these | |
two "levels": the types A and B. | |
#} | |
{% if record.contenttype.slug == "sections" and record.taxonomy.chapters is defined %} | |
{% setcontent subitems = 'sections' where { chapters : record.taxonomy.chapters|first } %} | |
{% set subitems = []|merge(subitems) %} | |
<ul class="sections-menu"> | |
{% set currentOnderdeel = false %} | |
{% for item in subitems %} | |
{% if item.sectiontype|lower != "artikel" and subitems[loop.index0 - 1].sectiontype|lower == "artikel" %} | |
</ul></li> | |
{% else %} | |
</li> | |
{% endif %} | |
<li class="{{ item.sectiontype|lower }}{% if item.slug == app.request.get('slug') %} active{% endif %}"> | |
{# <small>{{ loop.index0 }} - {{ item.sectiontype|lower }}</small> #} | |
{{ item.title }} | |
{% if item.sectiontype|lower != "artikel" and subitems[loop.index0 + 1].sectiontype|lower == "artikel" %} | |
<ul> | |
{% endif %} | |
{% endfor %} | |
</ul> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment