Paul Greinke Posted September 16, 2022 Share Posted September 16, 2022 I have a strange behavior when I try to merge two PageArrays. The example below creates unwantedly a PaginatedArray. Could someone explain why? I need the result not to be a PaginatedArray but a normal PageArray. <?php $pageArray = wire('pages')->find('template=release,name%=a'); $pageArray->import(wire('pages')->find('template=release,name%=b')); // $pageArray is now a PaginatedArray ?> I know I could do something like wire('pages')->find('template=release,name%=a|b') but my real case the two selectors are more complex. Why does ProcessWire create a PaginatedArray and is there a way to prevent that or at least to deconstruct the PaginatedArray back into a PageArray with all entries? Link to comment Share on other sites More sharing options...
Gideon So Posted September 16, 2022 Share Posted September 16, 2022 Hi @Paul Greinke How about this? <?php $pageArray_a = wire('pages')->find('template=release,name%=a'); $pageArray_b = wire('pages')->find('template=release,name%=b'); $pageArray_a = $pageArray_a->append($pageArray_b); ?> Gideon 1 Link to comment Share on other sites More sharing options...
Paul Greinke Posted September 16, 2022 Author Share Posted September 16, 2022 Thanks for the quick response @Gideon So. Unfortunately this does not solve the problem. I still get an PaginatedArray as the result. Link to comment Share on other sites More sharing options...
Gideon So Posted September 16, 2022 Share Posted September 16, 2022 Hi @Paul Greinke All page array in ProcessWire is PaginatedArray. Is the following suit your need? $array = $wireArray->getArray(); Get a PHP array of all the items in this WireArray with original keys maintained https://processwire.com/api/ref/wire-array/get-array/ Gideon Link to comment Share on other sites More sharing options...
Paul Greinke Posted September 16, 2022 Author Share Posted September 16, 2022 37 minutes ago, Gideon So said: $array = $wireArray->getArray(); Unfortunately getArray() only returns the items of the current page in the PaginatedArray. I found out, that my code does actually work in ProcessWire 3.0.200. Only in 3.0.179 I get the behavior I described. So I'll just upgrade I guess. I read in the docs that append() is just an alias to add(). Also they accept PageArrays as the argument. Do you know if import() does anything different? 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