Jump to content

Recommended Posts

Posted

Let's say I've got a template with a field of a Page type. This field is set to handle multiple options (PageArray).

Now, I want to select all pages using this template, that have specific page set in the PageArray field.

Basically, something like this:

$pages->find('template=x pagearrayfield.contains=page1')

Is this possible? Any hints?

Thanks in advance.

Posted

$pages->find("template=x, pagearrayfield=1234"); // where 1234 is the page ID

// this will also work

$wanted_page = $pages->get(1234);

$pages->find("template=x, pagearrayfield=$wanted_page");

  • Like 6
Posted
$pages->find("template=x, pagearrayfield=$somepage");

Where $somepage might be a page or a or multiples ID's . If $somepage is a page object, it will converted to a string with it's ID so you don't have to write $somepage->id but you could.

$pages->find("template=x, pagearrayfield=1230");
$pages->find("template=x, pagearrayfield=1230|1233|1203");
  • Like 3
Posted

Thanks a lot. I actually tried to do it this way but kept getting errors that arrays can not be converted to strings, etc. Most probably I had made some silly mistake somehwhere, now I can't reproduce it. It works flawlessly. 

To make this thread a bit more useful for others I'll share the "discovery" I've made while tinkering with selectors and pageArray fields: the requests could be nested, like that:

$pages->find('template=x, pagearrayfield.pagearrayfieldNested.name=somethingsomething');

Probably a bit overhead for the database, but great feature nonetheless.

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
×
×
  • Create New...