Skip to content
Grav 2.0 is officially stable. Read the announcement →
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 · 810 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 Anna, 1 day ago
2 74 4 hours ago
Support · by gtx, 1 week ago
4 234 2 days ago
Support · by Paul Hodges, 2 weeks ago
13 283 5 days ago
Support · by Anna, 3 weeks ago
9 340 1 week ago
Support · by TomW, 2 weeks ago
4 192 2 weeks ago