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.

Support

Get number of child pages for menu styling

first-time theme

Solved by pamtbaau View solution

Started by Marco 6 years ago · 2 replies · 722 views
6 years ago

Hello, first post here!
I've been experimenting Grav for some weeks and I love it! Modular pages are a stunning feature so is its speed.
That said, I ended up trying to create a theme fitting my needs.
I'm not completely new to web programming however my (limited) experience has been paused for the last ten years and a lot has happened. I primarly worked with PHP + CSS 2 and a little bit of jQuery.
I decided to start with the minimal Pure CSS framework, here's the first issue: how do I output in HTML the number of pages of the menu? This is needed in order to use Pure's Grid System i nnavigation menu.
I tried children.count() but it doesn't seem to fit this case. Or maybe I'm using it the wrong way.
Thank you!
Marco

6 years ago Solution

@phmg701, Welcome to the forum!

I wonder what you need the count for as the 'Pure' theme uses a <ul> for its menu-items.

Anyway, to get the count of visible root pages, try: pages.children.visible.count
And to get the count of visible children of the current page: page.children.visible.count

Have a look at the docs on Theme Variables where the Page and Pages object are mentioned.

last edited 07/10/20 by pamtbaau
6 years ago

Thank you, this just works!
My aim is to build a photo gallery based off PureCSS grids and those variables will be useful.
But I'm still far from this point, I'm struggling with navigation menu 😅
I'm also trying to understand how the Docs work as I'm not that used to such schemes (coming from WordPress Codex).
Thank you!

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 60 15 hours ago
Support · by Anna, 3 days ago
2 66 18 hours ago
Support · by Justin Young, 19 hours ago
1 33 19 hours ago
Support · by Duc , 1 week ago
2 69 6 days ago
Support · by Colin Hume, 1 week ago
2 61 6 days ago