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

Page.modular() not returning true on modular pages

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

Hello, I'm trying to display a side navigation menu only under certain conditions, one of which is that the page is not modular. I haven't been able to get the page.modular()method to return true in my twig template when on a modular page. Even a simple {{ dump(page.modular()) }} returns false on both of the modular pages I have. What am I doing wrong? I'm sure the two pages I'm testing are modular.

10 years ago

I think the docs for the method are wrong or the method implementation is wrong. It returns true if the page is a modular child.

Until the mystery is solved, to get if the parent is a modular page, you can use

if (page.template == 'modular')

10 years ago

Aha, that makes total sense, Flavio. Thank you for the clarification and the suggestion to use the page template object. So I wonder when the page.modular() method would be useful, since you can't directly access a single modular child in the browser as far as I could tell. Maybe when looping through a collection or something?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2955 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago