How To hide modular page from menu

hi everybody,

i try to setup a modular page. is there a way to append a section to another section (folder _section1 and inside _section1a and _section1b)

or

hide this section from being displayed in menu.
at the moment i’m not that confident with twig templating but i tried to solve it inside the modular.html.twig with a conditional approach.

thank you very much in advance for help.

In your modular.md file you can set:

onpage_menu: false

That means modular pages from that collection won’t be included in the menu.

mh this didn’t work for me. my page structure is like this:

01.home
modular.md
_section1
section1.md
_section2
section2.md

section2 for instance should be not in menu. with the onpage_menu: false it is not working but i got it workin with an if statement inside the for loop {% for module in page.collection() %}.
but maybe there is an more intuitive way to solve this.

what theme are you using ?

my very own :slight_smile: i started from scratch to get knowledge

i tried someting like: {% if header.hidemenu != true %} before the

  • and putted the “hidemenu: true to header”
  • Your code is all good. I do this kind of tricks all the time. This is sort of power of grav that you can put configuration values in the page header. Anyways, by providing onpage_menu: false I was referring to antimatter and antimatter based templates where this thing works. You may take a look at navigation.html.twig in antimatter and check how it’s done.

    yes i did. but the header.hidemenu thing is not working. it works only with module.menu != ‘section2’ for example

    try

    {% if not page.header.hidemenu %}
    

    If you referring to header variables you always have to use page. prefix.

    yep even this i tried but it seems only be working if i tell the page name directly via the module.menu

    i have it. the answer is more or less easy. it has to be a MODULE rather than a PAGE so with “module.header.hidemenu” it works perfect. thinking MODULAR :slight_smile:

    The solution that you suggested worked well for me too, thanks!

    1. added the hidemenu parameter to the header of the .md page I wanted to hide
    hidemenu: true
    
    1. added the if condition to antimatter/templates/modular.html.twig
    {% if not module.header.hidemenu %}
       {% set current_module = (module.active or module.activeChild) ? 'active' : '' %}
       <li class="{{ current_module }}"><a href="#{{ _self.pageLinkName(module.menu) }}">{{ module.menu }}</a></li>
    {% endif %}
    ---