is it possible to create submenu from modular pages? Got side navigation like Services > One collection of services > list of additional infos , and am unable to display it
my subnav code:
{% set collection = page.find(’/zakroky’).collection %}
-
{% for page in collection %}
{% if page.visible %}
{% set activepage = (page.active) ? 'active' : '' %}
<li><a class="{{ activepage }}" href="{{ page.url }}">{{ page.menu }}</a>
{% if page.children %}
<ol class="">
{% for child in page.children %}
{% if child.visible %}
<li><a href="{{ child.url }}">{{ child.title }}</a</li>
{% endif %}
{% endfor %}
</ol>
{% endif %}
</li>
{% endif %}
{% endfor %}
Not sure 100% want you want, but take a look at this in the Antimatter theme:
You could probably adapt that logic to your needs.
yeah, sorry for that / but problem is, ive got
{% set collection = page.find('/services').children %}
and my services folder is modular listing of separate services and one of them is also modular part of it …pretty crazy stuff … hm…?
so i can only achieve listing of ALL topics, or none of them =[
{% set collection = page.find(’/services’).children %}
-
{% for page in collection %}
{% set activepage = (page.active) ? 'active' : '' %}
<li><a class="{{ activepage }}" href="{{ page.url }}">{{ page.title }}</a>
<!-- here i would like to have my submenu =] -->
</li>
{% endfor %}
{% set collection = page.find('/services').collection %}
<ul class="navigation">
{% for page in collection %}
{% if page.visible %}
{% set activepage = (page.active) ? 'active' : '' %}
<li><a class="{{ activepage }}" href="{{ page.url }}">{{ page.title }}</a>
{% if page.find('/services/first-services-which-have-another-modules-inside' ).children %}
show sub menu test
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
---
This macro in Antimatter loops through all the pages and even goes into the children in order to build a dropdown-capable menu.
You will notice it is checking for visible
pages, and as modular pages are not visible (ie don’t show up in a menu) it will filter them out. You could remove that, but then the problem is they are not routable
so you can’t have a URL to them directly. You would need to manually create a URL with an anchor or something to jump to part of the page. Then on the page itself you would have to the template output the appropriate anchor link tag.
but what if i want to check the structure from 2nd or certain level …not from root?
You could have a special if
check for a particular parent page so you perform your modular logic only on pages you choose.