Jump to content
Sign in to follow this  
dab

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

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 🙂 

Share this post


Link to post
Share on other sites

You could try

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

 

 

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...