PageArray class

PageArray is a paginated type of WireArray that holds multiple Page objects.

Please see the WireArray and PaginatedArray types for available methods, as they are not repeated here, except where PageArray has modified or extended those types in some manner. The PageArray type is functionally identical to WireArray and PaginatedArray except that it is focused specifically on managing Page objects.

PageArray is returned by all API methods in ProcessWire that can return more than one page at once. $pages->find() and $page->children() are common examples that return PageArray.

You can create a new PageArray using any of the methods below:

// the most common way to create a new PageArray and add a $page to it
$a = new PageArray();
$a->add($page);

// ProcessWire 3.0.123+ can also create PageArray like this:
$a = PageArray(); // create blank
$a = PageArray($page); // create + add one page
$a = PageArray([ $page1, $page2, $page3 ]); // create + add pages

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the PageArray class also inherits all the methods and properties of: PaginatedArray, WireArray and Wire.

Show class?             Show args?        

Common

NameReturnSummary 
PageArray::add($page)
$thisAdd one or more Page objects to this PageArray. 
PageArray::findOnePage(string $selector)
Page NullPageSame as find() or findOne() methods, but always returns a Page (whether Page or NullPage) 
PageArray::first Page null First item 
PageArray::getPage($key)
Page NullPageLike the base get() method but can only return Page objects (whether Page or NullPage) 
PageArray::getPageByID(int $id)
NullPage PageGet Page from this PageArray having given ID, or return NullPage if not present 
PageArray::getPageByName(string $name)
NullPage PageGet Page from this PageArray having given name, or return NullPage if not present 
PageArray::getSelectors()
Selectors string nullReturn the Selectors that led to this PageArray, or null if not set/applicable. 
PageArray::last Page null Last item 

Additional methods and properties

In addition to the methods and properties above, PageArray also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.163

Twitter updates

  • Quick weekly update covering this week's commits for the upcoming 3.0.167 ProcessWire core version— More
    18 September 2020
  • This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder— More
    11 September 2020
  • Weekly update – 28 August 2020 – New secure files option defined per-template: More
    28 August 2020

Latest news

  • ProcessWire Weekly #333
    In the 333rd issue of ProcessWire Weekly we'll check out what's new in the latest dev version of ProcessWire, 3.0.167, and more. Read on!
    Weekly.pw / 26 September 2020
  • ProcessWire 3.0.166 core updates and more
    This week ProcessWire version 3.0.166 is released on the dev branch. In this post we’ll cover all that’s new relative to the previous version, 3.0.165. Plus we’ll check out the latest new versions of ProCache and FormBuilder.
    Blog / 11 September 2020
  • Subscribe to weekly ProcessWire news

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.