Hide a certain modular subpage from the navigation bar


#1

Hello,
how can you hide a certain modular subpage from the navigation bar of the page?
greeting
Käpsele


#2

Try visible: false in the page frontmatter? If you are using the Admin Panel this option is also available when editing a page.


#3

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?


#4

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


#5

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”


#6

Awesome, great to hear you found a solution!


#7

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.


#8

Hi @werdi, what exactly do you want to do with Antimatter?


#9

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.


#10

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.


#11

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?


#12

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?


#13

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


#14

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 %}