Jump to content

Get child of $page.rootParent


Manaus
 Share

Recommended Posts

Hello, I have a site hyerarchy like this:

/projects/blue/

/projects/blue/posts/

/projects/blue/posts/comments/

How can I get always 'blue', wherever I am? Mind that I have many colors...

Thanks!

Link to comment
Share on other sites

Thanks Macrura, I only wish it was so easy...
The script is in a code I include in many pages, so it's highly dynamic
 
I tried $page->rootParent->child, but I get the first element of the array, which is always blue.

Link to comment
Share on other sites

How can I get always 'blue', wherever I am? Mind that I have many colors...

I tried $page->rootParent->child, but I get the first element of the array, which is always blue.

First you always want to get blue and then you don't want to always get blue. Can you please give more detail on what you actually want to achieve?

Link to comment
Share on other sites

Use parents() or closest(). If those color pages have a own template use that in the selector for closest() or parents(). Or parents()->eq(n) where n is the level of color pages.

  • Like 3
Link to comment
Share on other sites

Use parents() or closest(). If those color pages have a own template use that in the selector for closest() or parents(). Or parents()->eq(n) where n is the level of color pages.

Uhh, closest, I love that method, I use it in jQuery very frequently.

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...