Jump to content

Get page level in parent/child tree?


FuturShoc
 Share

Recommended Posts

Can someone suggest a way to get the *level* of a page in the hierarchy?

I need to do something different on a page template, IF the page exists at the third level of the page hierarchy.

I was hoping for some kind of $page->level() method I could call, but that doesn't seem to exist.

Link to comment
Share on other sites

Aha! That seems to give us what we need. Thanks, Ryan.

Off the cuff, I wouldn't have expected that to work since I see "parents" as however many siblings exist above the current level.

But, clearly, the parent/child model doesn't work *quite* like genetics. ;-)

Link to comment
Share on other sites

Off the cuff, I wouldn't have expected that to work since I see "parents" as however many siblings exist above the current level.

But, clearly, the parent/child model doesn't work *quite* like genetics. ;-)

A page does not need to have two parents of the same generation like we do. In the case of ProcessWire, all pages are female. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...