Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Subpages in menu

Started by Muut Archive 10 years ago · 9 replies · 2203 views
10 years ago

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.

10 years ago

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.

10 years ago

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.

10 years ago

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 ? :/

10 years ago

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

10 years ago

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.

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

Also tried :

YAML
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 ! :)

10 years ago

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.

10 years ago

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

Thanks anyway sir, help was appreciated !

10 years ago

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

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

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 ! :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1361 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1123 9 years ago