$page


Built-in Methods Reference

  • $page->find($selector)

    Find pages matching the selector anywhere below this page (children, grandchildren, etc.). Returns a PageArray.

  • $page->get("field")

    Get the value for the specified field or null if the field isn't part of this page. Same as $page->$field

  • $page->get("field1|f2|f3")

    Get the first matching non-empty field by specified by a string of pipe "|" separated field names

  • $page->getUnformatted("field")

    Get the unformatted value of the given field name. May also be used with "|" separated field names (mentioned above).

  • $page->setOutputFormatting(true|false)

    By default, output will be formatted according filters you may have defined with the field. If you are modifying the values of a page's custom fields, you will need to call $page->setOutputFormatting(false) before doing so. This turns off output formatting, which ensures that saved values don't already have runtime formatters applied to them. ProcessWire will throw an error if you attempt to save formatted fields.

  • $page->of(true|false)

    This is the short notation of setOutputFormatting(). Since PW 2.2.2

  • $page->numChildren(bool)

    Return number of children, optionally limiting to visible pages. When true, number includes only visible children (excludes unpublished, hidden, no-access, etc.)

  • $page->children($selector)

    Returns the filtered children (PageArray) of this page, optionally filtered by a selector.

  • $page->child($selector)

    The first matching child (subpage) that matches the given selector. Returns a Page, or a NullPage if no match.

  • $page->siblings($selector)

    All the sibling pages of this page, filtered by a selector.† Returns a PageArray.

  • $page->parent($selector)

    Return this page's parent Page, or the closest parent matching the given selector.

  • $page->parents($selector)

    Return this page's parent pages, or the parent pages matching the given selector.

  • $page->parentsUntil($selector, $filter)

    Return all parents from current till the one matched by $selector. $selector May either be a selector string or Page to stop at. Results will not include this. $filter Optional selector string to filter matched pages by

  • $page->closest($selector)

    Like parent() but includes the current Page in the possible pages that can be matched. Note also that unlike parent() a $selector is required.

  • $page->next($pageArray)

    Given a PageArray which includes the current page (among others), return the next page after the current.† Returns a NullPage if it is the last page in the provided PageArray. If called without a PageArray, it assumes the current page's siblings (same as $page->next).

  • $page->nextAll($selector, $siblings)

    Return all sibling pages after this one, optionally matching a selector. $selector Optional selector string. When specified, will filter the found siblings. $siblings Optional siblings to use instead of the default.

  • $page->nextUntil($selector, $filter, $siblings)

    Return all sibling pages after this one until matching the one specified. $selector May either be a selector string or Page to stop at. Results will not include this. $filter Optional selector string to filter matched pages by. $siblings optional PageArray of siblings to use instead of all from the page.

  • $page->prev($pageArray)

    Given a PageArray which includes the current page (among others), return the previous page before the current.† Returns a NullPage if it is the first page in the provided PageArray. If called without a PageArray, it assumes the current page's siblings (same as $page->prev).

  • $page->prevAll($selector, $siblings)

    Return all sibling pages before this one, optionally matching a selector. $selector Optional selector string. When specified, will filter the found siblings. $siblings Optional siblings to use instead of the default.

  • $page->prevUntil($selector, $filter, $siblings)

    Return all sibling pages before this one until matching the one specified. $selector May either be a selector string or Page to stop at. Results will not include this. $filter Optional selector string to filter matched pages by. $siblings Optional PageArray of siblings to use instead of all from the page.

  • $page->save()

    Save this Page

  • $page->save($field)

    Save just the field given by the provided field name (string) or object (Field)

  • $page->delete()

    Delete this page

  • $page->is($name)

    Returns true if this page matches the given template name, page status, or selector.

  • $page->isChanged()

    Has the $page changed since it was loaded? Returns true or false.

  • $page->isChanged("field")

    Has the given field on $page changed since it was loaded? Returns true or false.

  • $page->isNew()

    Is this Page new? (i.e. doesn't yet exist in DB)

  • $page->isHidden()

    Returns true if page has status hidden.

  • $page->isTrash()

    Returns true if page is in trash.

  • $page->matches("selector")

    Returns true if this page matches the given selector string.

  • $page->render()

    Returns rendered page markup. echo $page->render();

  • $page->set("field", $value)

    Set the given custom field name to have the provided value. Same as $page->$field = $value;

  • $page->editable()

    Is the page is editable by the current user? Returns true or false.

  • $page->editable('field')

    Is the given field name is editable on the page by the current user? Returns true or false.

  • $page->viewable()

    Is the page viewable by the current user? Returns true or false. Note that this is only useful on pages other than the current page being viewed, as ProcessWire won't let the user load a page (by URL) that they don't have access to view.

  • $page->addable()

    Is the current user allowed to create pages below this page? Returns true or false.

  • $page->addable($addPage)

    Is the current user allowed to add the given page ($addPage) as a child of $page? Returns true or false.

  • $page->moveable()

    Is the page allowed to be moved by the current user? Returns true or false.

  • $page->moveable($parent)

    Is the current user allowed to move $page to $parent? Returns true or false.

  • $page->sortable()

    Is the page sortable (within the same parent) by the current user? Returns true or false.

  • $page->deleteable()

    Is the page deleteable by the current user? Returns true or false.

  • $page->addStatus(Page::statusHidden)

    Add a status to this page.

  • $page->removeStatus(Page::statusHidden)

    Removes a status from this page.