Jump to content

page parents, parents until, question


Martinus
 Share

Recommended Posts

Hi all,

I am experimenting on a new site.
My page structure:

- root / company (rootparent) / north / simple / product
- root / company (rootparent) / south / advanced / product 

template names:

- home / company / location / category / product

When I am on a product-index page, I retrieve all products going after the template 'product'. 
I also want the product parents (recursive), AND for only 2 levels. Is this possible with the following code from the docs? 

foreach($product->parents(true) as $parent) {
  echo "<li><a href='$parent->url'>$parent->title</a></li>";
}

 

I have also found this code which seems to limit results until the one I use as selector. But that one does not work recursive:

$items = $product->parentsUntil('template=company');
  foreach($items as $item) {
    echo $item->name;
  }

Any help is appreciated.

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