Subpages in menu

Hi,

I’m just starting to use Grav and i think it’s an amazing tool. However, I’m trying to display subpages in the menu.

I am using receptar skeletton/theme and I’d like to display subpages in blogs folder (ie : /user/pages/01.blog/*/item.md) in the main menu. I could have created folders for each page in /user/pages/ but I’d like to show preview on the main page (/blog) like blog posts.

Can someone give me a hint, or something, a trick to do this ?

Thanks in advance,
G.

First remember that the numeric prefix on the folder ‘by default’ makes a page visible. This in turn means it will show up in a menu. Most blog type skeletons don’t want blog items in a menu, so they typically don’t have this folder prefix on their page folders. You can override this behavior by setting visible: true in the page header (or via admin).

Next just setting the page to be visible, has to be matched with a theme that supports showing submenu items. I’m not familiar with the Receptar theme, but you can use Antimatter as a good example.

It has a macro with logic in the templates/partials/navigation.html.twig file that loops through top-level pages, then if there are children, and they are visible, it loops through those too. It keeps recursing and outputting a nested list that is then styled via CSS to only display as you hover. Standard stuff really.

I’ll give a try right now. Thanks for the quick reply ! I did not thought about numeric prefix on subfolders !

I’ll give you a feedback when it’s done. Thanks again.

It dosn’t seems to work… I added visible: true in the header of my subage (user\pages\01.blog\01.a-very-delicious-blog) item.md (and btw, added the numeric prefix) and I can’t make it appears in the menu. I cleared the cache, I checked navigation.html.twig and it is pretty similar to the Antimatter one…

Any clue ? :confused:

Stupid question, but did you enable dropdown.enabled in the Receptar theme config????

Hi !
I’m assuming that the receptar config is \user hemes\receptar\receptar.yaml . In that case, there is no option to enable it. I tried adding dropdown.enabled: true, dropdown.enabled (alone) and it doesn’t seems to work.

enabled: true
default_lang: fr
dropdown.enabled: true
streams:
  scheme:
    theme:
      type: ReadOnlyStream
      paths:
        - user/themes/receptar

Also tried :

enabled: true
default_lang: fr
dropdown:
  enabled: true
streams:
  scheme:
    theme: 
      type: ReadOnlyStream
      paths:
        - user/themes/receptar

Because of {% if theme_config.dropdown.enabled %}

Thanks for helping me rhukster . Much apppreciated ! :slight_smile:

Mmm… looks like in Receptar the dropdown is available, but there’s no configuration option to enable it.
The correct path is user/config/themes/receptar.yaml. The second file content you added should work fine.

The best way to tell if a config is working is to edit the page (in this case https://github.com/getgrav/grav-theme-receptar/blob/develop/templates/partials/navigation.html.twig) and add a dump() call or just enter a word inside the if.

I can’t make the config work :(. It’s driving me crazy :frowning: . I’m going to hardcode it. Don’t wanna spend too much time for this ^^

Thanks anyway sir, help was appreciated !

I checked, the theme does not actually implement dropdown, but showing subpages. Check https://github.com/getgrav/grav-theme-receptar/issues/5#issuecomment-205216674 I posted a PR to add a configuration option in the Admin theme config to enable it

It works perfectly well ! You’re my hero sir !

(That will be helpful for the futur. Adding config to a theme :slight_smile: )

That would have saved me a lot of time 2 days ago ^^. I’ll remember this for my next website :).

Have a nice days guys ! :slight_smile: