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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Hiding private pages from menu

Started by Muut Archive 10 years ago · 2 replies · 2375 views
10 years ago

Hi all, I'm new to Grav and I love it (a blessing compared to WP). I still have a lot to learn and to experiment, now I have a question about the menu (using Antimatter)
I've managed to create a protected page (and subpage), the visitor has to login to view them (so far so good). The title of this protected page (and subpage) appears in the menu, even if the visitor is not logged in.
Is it possible to (automatically) hide these pages from the menu until the visitor has logged in?

10 years ago

Currently this is not something the login plugin provides. It assumes the page is visible, you can navigate there, but are prompted to login if you don't have access.

Hiding the menu can be done by performing the logic in the theme's twig template that outputs the menu. Basically you would have to ensure the current logged in user (grav.user) has access that matches the page.header.access for the page as you build the menu.

The better solution would be if the login plugin has an option to do this. I've created an issue there for a future improvement: https://github.com/getgrav/grav-plugin-login/issues/87

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1281 9 years ago
Archive · by Muut Archive, 9 years ago
2 888 9 years ago
Archive · by Muut Archive, 9 years ago
2 4018 9 years ago
Archive · by Muut Archive, 9 years ago
1 2894 9 years ago
Archive · by Muut Archive, 9 years ago
3 1077 9 years ago