Menus & Modular pages

I’m using Grav 1.7rc running on a docker container, with the default Quark theme.

I have 3 modular pages on root with each one having a Hero element. Something like this:

.
├── 01.home
│   ├── modular.md
│   └── _banner
│       ├── hero.md
│       └── man-holding-remote-control-1040160.jpg
├── 02.home-2
│   ├── modular.md
│   └── _banner
│       ├── hero.md
│       └── man-holding-remote-control-1040160.jpg
└── 03.home-3
    ├── modular.md
    └── _banner
        ├── hero.md
        └── man-holding-remote-control-1040160.jpg

The problem is that there is no menu entry for any of them, since I make the hero sub-modules invisible.

What am I missing guys? The Default pages get menu entries just fine but my guess is that due to the nature of the Modular pages I’m missing something in my workflow.

Any assistance or guidance to the right tutorial/video/documentation page would be appreciated.

Thank you in advance

@GNUTechie, Not sure what you are expecting the menu to look like.

Modular pages can show two different menus depending on the value of onpage_menu set in ‘modular.md’:

  1. onpage_menu: false
    The menu will contain the sibling pages of the current page. In your case that would be Home1 - Home2 - Home3. You will not see the children in the menu.
  2. onpage_menu: true
    The menu will contain the children of the modular page as menu items.
    In your case the value of ‘menu’ set in ‘_banner/hero.md’.
    Since the modular page shows its own children as menu-items, you won’t find Home2 and Home3 in the menu.

I presume you want to see the children of the modular page. In that case, you won’t see Home2 and Home3 in the menu.

since I make the hero sub-modules invisible.

Not sure why you would want to set a child module ‘visible: false’. In that case you won’t indeed see hero.md appear in the menu. See the docs on Visible:

By default, a page is visible in the navigation […] This behavior can be overwritten by setting the visible variable in the header.

onpage_menu: true didn’t work for me. I still don’t get any menu items on the navigation section of any of the modular pages. However and here’s the kicker for me… if I add another page (a Default one) off of the root, thus making my site’s structure like this:

.
├── 01.home
│   ├── modular.md
│   └── _banner
│       ├── hero.md
│       └── man-holding-remote-control-1040160.jpg
├── 02.home-2
│   ├── modular.md
│   └── _banner
│       ├── hero.md
│       └── man-holding-remote-control-1040160.jpg
├── 03.home-3
│  ├── modular.md
│  └── _banner
│      ├── hero.md
│       └── man-holding-remote-control-1040160.jpg
└── 04.test
    └── default.md

and view that fourth page I can see all pages (home, home-2, home-3 and test) listed in the navigation section and the links point to each page.

So is onpage_menu different between the default and the modular pages? And if so how can i change it so I can get the navigation to work?

And is this behavior specific to the quark theme or is it present in all themes?

@GNUTechie, A bit more clarification:

  • onpage_menu is only used for modular pages. It does not make sense in other page types (regular and listing). See page types and modular.

  • A regular/listing page will always show the visible root pages in the menu.

  • A modular page will display either the visible pages in its collection (when onpage_menu: true), or the visible root pages (onpage_menu: false).

    The default behaviour of a modular is onpage_menu: true

  • A page for which visible: false has been set, will not show up in the menu.

In pseudo code for modular page:

if (modular.onpage_menu != false) {
  for (module in modular.collection) {
    if (module.visible != false) {
      // show module in menu
    }
  }
} else {
  for (page in root.children) {
    if (page.visible == true) {
      // show page in menu
    }
  }
}

Since the menu of you modulars are empty, I presume:

  • The modular has not set onpage_menu: false
  • The module has set visible: false

That did the trick for me. I used a value of true initially thinking that onpage_menu needed it to do its checks but from your pseudocode I see that it works in reverse (goes to the else branch if it’s equal to false).

Thank you very much for clarifying that in such detail.

Does the pseudocode for the modular page apply to all modular pages by default regardless of theme? Or do themes override this branching?

@GNUTechie, Themes can do anything they like…

The Grav theme has created the concept of modular pages and created the first themes using it. I (like to) think that all other theme builders are sensible copycats and stick to the convention. I haven’t seen an exception yet…

Do you have any reason to doubt?