Jump to content

How to find pages and build links but dont show the link if its the same as $page or $page->parents


cb2004
 Share

Recommended Posts

I am creating some calls to action and I am banging my head against the wall for something which I know is simple. Lets say my structure is:

- Books (id = 1)
 -- Book Year
 --- Book

- Videos (id = 2)
 -- Video Year
 -- Video

So on my whole template in a side bar I want to link to Books and Videos so:

$ctas = $pages->find("id=1|2, sort=sort");

Nice and simple. To stop the link to itself when I am on the page this is:

$ctas = $pages->find("id=1|2, id!=$page, sort=sort");

But lets say I am in Book Year or Book, I don't want to display a link to the parent Books as I am already in a child and this is handled by breadcrumbs.

I have tried so many selectors I think I have exhausted them all, so I must be missing something.

Cheers.

Link to comment
Share on other sites

Awesome work DaveP, with some brackets around the $page->parents we got there:

$ctas = $pages->find("id=1|2, id!={$page->parents->append($page)}, sort=sort;

Virtual beer your way Sir.

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