Frank Vèssia Posted October 4, 2012 Posted October 4, 2012 I have this selector $photos = $pages->find("template=picture,has_parent=2293|1038,limit=20,sort=-created"); I got this warning even i can show correctly my photos... Warning: preg_match() expects parameter 2 to be string, array given in /public_html/wire/core/Sanitizer.php on line 266/ 1
diogo Posted October 4, 2012 Posted October 4, 2012 I think has_parent is not a selector. try parent=2293|1038 Sorry, it is a selector...
Frank Vèssia Posted October 4, 2012 Author Posted October 4, 2012 Yes, it'a a selector and the strange thing is the result is showed correctly...
apeisa Posted October 4, 2012 Posted October 4, 2012 Are you sure it is that exact place that is causing the warning?
Frank Vèssia Posted October 4, 2012 Author Posted October 4, 2012 Absolutely, I removed all other stuff i have...using just one ID it works without warnings...
Frank Vèssia Posted October 4, 2012 Author Posted October 4, 2012 oh, that's pitty...any workaround to obtain the same?
apeisa Posted October 4, 2012 Posted October 4, 2012 Actually it says otherwise: You can specify a Page object, Page ID, or path, like shown above. Note however that at present, you can only specify one page at a time here (meaning no has_parent=1|2|3).
Frank Vèssia Posted October 4, 2012 Author Posted October 4, 2012 Yes, infact i need to specify more than one page...
Soma Posted October 4, 2012 Posted October 4, 2012 like this? $parents = array(2293,1038); $photos = new PageArray(); foreach($parents as $parent) $photos->add($pages->find("template=picture,has_parent=$parent,limit=20,sort=-created")); $photos = $photos->sort("-created")->slice(0,20);
Frank Vèssia Posted October 4, 2012 Author Posted October 4, 2012 Soma, that works, a good solution, but in my case i need to paginate the result, for this reason i used the limit, but it looks like the built in pagination to this final PageArray doesn't work...
Soma Posted October 4, 2012 Posted October 4, 2012 In that case you need to construct your own pagination. Pagination only works with 1 page query.
ryan Posted October 5, 2012 Posted October 5, 2012 has_parent only works with 1 page because the only reason it exists is to provide the Page::find() capability -- or at least, that was the original intention. I'm not sure what the structure you have is exactly, but you can use "|" with parent. So if you could narrow it down to the parents, then you could do it. Something like this might provide an equivalent functionality, though not ideal if the potential number of parents is huge. $parents = new PageArray(); $hasParents = $pages->find("id=2293|1038"); foreach($hasParents as $hasParent) { $parents->add($hasParent->find("num_children>0, template!=picture")); } $selector = "template=picture, sort=-created, limit=20, parent="; foreach($parents as $parent) $selector .= $parent->id . "|"; $photos = $pages->find(rtrim($selector, '|'));
Frank Vèssia Posted October 8, 2012 Author Posted October 8, 2012 Thanks Ryan but i solved the problem in another way, I changed my structure and removing one intermediate page between the parent I'm looking for and the piciture page, so now i can use the direct "parent="
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