Jump to content

Create new wireArray


thomas
 Share

Recommended Posts

Hello,

still trying to understand everything ... I have an array of page IDs, now I want to push the pages with those IDs into a wireArray to use the PW methods on it, like limit and sort. How can I create a new wireArray to hold those pages? I tried

$rp = $pages->makeNew();

but get an error ("Error Exception: Method Pages::makeNew does not exist or is not callable in this context")

Thanks for help!

thomas

Link to comment
Share on other sites

Something like this can be used to create a new PageArray

$somepages = $pages->find("template=news, limit=10");
$parray = new PageArray();
$parray->add($somepages); // add one page (or also multiple since 2.2.2)
// or
$parray->import($somepages); // add one or multiple pages from another PageArray
$parray->sort("-modified");
...

Edit:

If you have an array with id's that's also cool:

$ids = array(1002,1004,2303,4342);
$parray = new PageArray();
foreach( $ids as $id ) $page->id ? $parray->add( $page->get($id) ) : continue ;
  • Like 4
Link to comment
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
 Share

×
×
  • Create New...