Jump to content

Find pages with a field matching $page->parent->title


dab
 Share

Recommended Posts

Stumped with this....please can anyone help?

I'm trying to find pages with a field that matches the search page's parent's title.

This works 

$items = $pages->find('template=items-ordered,supplier=Acme Biscuits');

Not this...(did no find any pages).

$items = $pages->find('template=items-ordered,supplier=$page->parent->title');

With thanks 🙂 

Link to comment
Share on other sites

You need double quotes. If you had debug on, this would have thrown an exception:

1 hour ago, dab said:

$items = $pages->find('template=items-ordered,supplier=$page->parent->title');

Change it to this:

$items = $pages->find("template=items-ordered,supplier={$page->parent->title}");

 

  • Like 1
Link to comment
Share on other sites

Many thanks! Both worked. I had tried with {....} but obviously also needed the double quotes. I was outputting directly to .csv which was clearly not the best way to debug! Thanks again.

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