Jump to content

$pages->import() creates pagination


Paul Greinke
 Share

Recommended Posts

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

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

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

  • Recently Browsing   0 members

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