BartekG Posted June 12, 2014 Share Posted June 12, 2014 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. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted June 12, 2014 Share Posted June 12, 2014 $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"); 6 Link to comment Share on other sites More sharing options...
Soma Posted June 12, 2014 Share Posted June 12, 2014 $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"); 3 Link to comment Share on other sites More sharing options...
BartekG Posted June 13, 2014 Author Share Posted June 13, 2014 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now