Jump to content

Recommended Posts

Posted

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/
  • Like 1
Posted

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

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);
Posted

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

Posted

In that case you need to construct your own pagination. Pagination only works with 1 page query.

Posted

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, '|')); 
Posted

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="

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...