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($item)
$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.236

Latest news

  • ProcessWire Weekly #518
    The 518th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 13 April 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer