Hello,
how can you hide a certain modular subpage from the navigation bar of the page?
greeting
Käpsele
Try visible: false
in the page frontmatter? If you are using the Admin Panel this option is also available when editing a page.
Thanks for your answer!
Yes, i did this, but it doesn`t works.
I have found this option in the “Normal”-tab, not in the Advanced-tab.
Have you another idea for solution?
Hmm… I thought that would have worked, what theme are you using? Did you clear the cache after trying the setting? By ‘modular subpage’ what exactly do you mean?
Here is more info from the docs: https://learn.getgrav.org/content/headers#visible
I use Template “Halcyon”.
The cache is disabled.
I’ve seen it work in another template.
Possibly. Can I take the code from there?
Edit:
i have the solution: write in the page-header: “hidemenu: true”
Awesome, great to hear you found a solution!
How would you solve this in the “Antimatter” theme? I’ve tried what you write here and also in different other threads, but it seems not to work on Antimatter.
Hi @werdi, what exactly do you want to do with Antimatter?
Hi Paul,
thanks so much for your reply.
The question is about how to hide a certain modular subpage from the navigation bar.
For example:
01.home
_subpage1
_subpage2
_subpage3
Imagining you want to hide subpage 2 from the navigation bar.
You suggested a helpful solution in this thread for the Halycon theme (i believe), which includes pasting some code in the modular.html.twig file. That didn’t work for my Antimatter theme.
Do you know a solution for the Antimatter theme?
Thanks so much.
Hi @werdi , you could add a check for page visibility in the modular.html.twig
, like this:
{% for module in page.collection() %}
{% if module.header.visible %}
{% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
<li class="{{ current_module }}"><a href="#{{ _self.pageLinkName(module.menu) }}">{{ module.menu }}</a></li>
{% endif %}
{% endfor %}
And then in each of your modular pages set visible to true or false, like this:
visible: true
Let me know if that works for you.
Thanks for your answer. I tried it and it seems to confuse things. The item in question appears twice on the navigation, instead of disappearing. Did I get something wrong?
Please ignore my last message. It didn’t work - (and the double appearance was a mistake on my part, but still it didn’t work). What am I missing?
What exactly happened? Here is a link to my test user folder for you to try:
https://ln.sync.com/dl/191446010/v6tuh2pb-nrnx99xa-pevg7wua-skyistub
Also, just in case you do not know this any changes to the actual Theme files may be lost if the theme is updated. Set up an inherited theme to avoid this, as described at https://learn.getgrav.org/themes/customization#theme-inheritance
This was a great tips. I used it for Quark “on-page” menu in modular.html.twig file inside block “{% block header_navigation %}”:
{% for module in page.collection() %}
{% if module.header.visible == true %}
{% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
<li><a class="{{ current_module }}" href="#{{ _self.pageLinkName(module.menu) }}">{{ module.title }}</a></li>
{% endif %}
{% endfor %}