Page / $page

Many types of content in ProcessWire are represented by the Page class and descending classes

Pages live in a tree hierarchy and carry typed field values defined by their template. The $page API variable refers to the current requested page. And the $pages API variable provides methods for retrieving pages from the tree.

Custom user-defined page classes that extend the Page class live in /site/classes/.

Native properties

These properties are available on every page regardless of template:

PropertyTypeDescription
idintDatabase ID (0 for unsaved pages, 0 for NullPage)
namestringURL segment name — unique among siblings
titlestringHuman-readable title (custom field but almost always present)
statusintBitmask of status flags (see status constants below)
statusStrstringSpace-separated string of status names active on page.
templateTemplateThe page's template object
parentPageImmediate parent page
parentsPageArrayAll ancestor pages, root first
rootParentPageTop-level parent (child of homepage)
childrenPageArrayImmediate children (published, visible, with access)
pathstringURL path from root, e.g. /about/team/
urlstringFull URL (same as path if no subdirectory install)
httpUrlstringAbsolute URL including scheme and hostname
editUrlstringAdmin edit URL for this page
createdintUnix timestamp of creation
createdStrstringCreated date/time as ISO-8601 string
modifiedintUnix timestamp of last modification
modifiedStrstringLast modified date/time as ISO-8601 string
publishedintUnix timestamp of publication
publishedStrstringPublication date/time as ISO-8601 string
createdUserUserUser who created the page
modifiedUserUserUser who last modified the page
numChildrenintNumber of direct children (no exclusions)
hasChildrenintNumber of direct visible children. Excludes unpublished, no-access, hidden, etc.
sortintSort order relative to siblings when sortfield is 'sort'
sortfieldstringProperty or field that children sorted by (or 'sort' for manual)
filesManagerPagefilesManagerManages files and file directories for a page independent of a particular field.

For a full list of page properties, see the phpdoc header of the Page class or the Page API reference.

Getting and setting values
// Get a field value (output formatting ON by default in template context)
echo $page->title;
echo $page->body;
echo $page->get('title'); // same as $page->title

// Set a field value (turn off output formatting first)
$page->of(false);
$page->title = 'New Title';
$page->save('title'); // save just one field
$page->save();        // save all changed fields
$page->setAndSave('title', 'New Title'); // combined set + save

// Get raw unformatted value regardless of output formatting state
$raw = $page->getUnformatted('body');

// Get formatted value regardless of output formatting state
$formatted = $page->getFormatted('body');

// Get multiple values at once (returns array keyed by field name)
$values = $page->getMultiple(['title', 'body', 'images']);

Output formatting: of()

Output formatting determines whether field values pass through runtime text formatters (e.g. Markdown, HTML entities, etc.)

$page->of(false); // turn OFF — use when modifying values
$page->of(true);  // turn ON  — use for front-end output (default in template context)
$current = $page->of(); // returns current state (bool) without changing it

Always call $page->of(false) before setting and saving values. And if you will be making modifications to an existing value, make sure to $page->of(false) before getting the value you will modify. You do not want to have a formatted value get saved in the database.

Flexible get() syntax

get() accepts several formats beyond a plain field name:

// OR-pipe: return first non-empty value among listed fields
$page->get('summary|body|title');

// Dot notation: traverse into sub-objects
$page->get('category.title');       // title of related page
$page->get('images.first.url');     // url of first image

// Bracket notation: access items within a multi-value field
$page->get('images[]');             // all items as array
$page->get('images[0]');            // first item
$page->get('images[tag=hero]');     // item matching selector

// Format string: fill a pattern with property values
$page->get('{title} ({id})');
Saving and deleting
// Save all changed fields
$page->save();

// Save a specific field only
$page->save('title');
$page->saveFields(['title', 'body']); // save several fields

// Save without updating modified user and timestamp
$page->save(['quiet' => true]);

// Set value and save in one call, works even if output formatting on
$page->setAndSave('headline', 'Hello World');

// Set and save multiple fields
$page->setAndSave([
    'title' => 'It is Friday again',
    'subtitle' => 'The best day of the week is Friday',
    'body' => '<p>This is my short blog post...</p>'
]);

// Trash a page (moves to trash, recoverable)
$page->trash();

// Delete a page permanently
$page->delete();

// Delete a page and all its children
$page->delete(true);
Traversal

Children and descendants

When we refer to "accessible" pages below, it means pages that are published, not hidden, and that the curent user has access to.

// Direct accessible children (published + visible + current user has access)
foreach($page->children() as $child) { ... }
$page->children('sort=title, limit=10'); // with selector

// First accessible child
$first = $page->child();

// First created and accessible child
$first = $page->child('sort=created');

// First created child with no exclusions (skips access and status checks)
$first = $page->child('sort=created, include=all');

// Last created child with no exclusions
$last = $page->child('sort=-created, include=all');

// Find among all accessible descendants, like $pages->find() but scoped to this page
$results = $page->find('template=product, featured=1');
$result  = $page->findOne('sku=ABC123');

// Number of children and descendants
$n = $page->numChildren();             // number of children with no exclusions
$n = $page->numChildren;               // same as above but as property
$n = $page->numChildren(true);         // number of accessible children
$n = $page->numChildren("foo=bar");    // count of children matching selector
$n = $page->numDescendants();          // number of descendants, no exclusions
$n = $page->numDescendants(true);      // number of accessible descendants
$n = $page->numDescendants("foo=bar"); // number of descendants matching selector

Parents and ancestors

All of the following method calls without arguments can also be accessed as properties, i.e. $page->parent() can also be accessed as $page->parent.

$parent = $page->parent();                     // immediate parent 
$parents = $page->parents();                   // all ancestors, root first
$parents = $page->parents('template=section'); // filtered ancestors
$root = $page->rootParent();                   // top-level ancestor
$n = $page->numParents();                      // depth in tree

Siblings

$siblings = $page->siblings();                 // all siblings including self
$siblings = $page->siblings(false);            // all siblings excluding self
$siblings = $page->siblings('sort=title');     // sorted siblings (or any selector)
$siblings = $page->siblings('foo=bar', false); // filtered siblings (excluding self)

$next = $page->next();                         // next sibling
$prev = $page->prev();                         // previous sibling
$next = $page->next('template=product');       // next matching sibling

$after  = $page->nextAll();                    // all following siblings
$after  = $page->nextAll('foo=bar');           // all following siblings, filtered
$before = $page->prevAll();                    // all preceding siblings

// All siblings up to (not including) first one matching the selector
$until = $page->nextUntil('template=divider');
$until = $page->prevUntil('template=divider');

Position

$n = $page->index();        // 0-based position among accessible siblings
$n = $page->index(true);    // same as above but with no exclusions
Status

Status constants

ConstantValueMeaning
statusLocked4Protected from editing in the admin
statusHidden1024Hidden from front-end listings
statusUnpublished2048Unpublished — not publicly accessible
statusTrash8192Page is in the trash
statusDeleted16384Deleted (runtime only, not saved)
statusSystemID32768System page that cannot be renamed
statusSystem65536System page that cannot be deleted or renamed
statusCorrupted536870912Page data is corrupt — do not save

Checking status

// Preferred: named methods
if($page->isHidden()) { ... }
if($page->isUnpublished()) { ... }
if($page->isLocked()) { ... }
if($page->isTrash()) { ... }
if($page->isPublic()) { ... } // published and guest-viewable

// Generic check
if($page->hasStatus(Page::statusHidden)) { ... }
if($page->hasStatus('hidden')) { ... }            // string form

// is() — checks status name, template name, or selector
if($page->is('hidden')) { ... }
if($page->is('template=product')) { ... }

// Numeric and bitwise status comparisons
if($page->status < Page::statusUnpublished) { ... } // page is published
if($page->status < Page::statusHidden) { ... }      // page published and not hidden
if($page->status & Page::statusHidden) { ... }      // page is hidden

Modifying status

$page->addStatus('hidden');                     // add by name
$page->addStatus(Page::statusHidden);           // add by constant
$page->removeStatus('hidden');                  // remove by name
$page->removeStatus(Page::statusHidden);        // remove by constant

// Set status directly (replaces current status)
$page->status = Page::statusHidden | Page::statusUnpublished; // bitwise
$page->status('hidden, unpublished');                         // string form
$page->status(['hidden', 'unpublished']);                     // array form

// Get array of current status names
$names = $page->status(true); // e.g. ['hidden', 'unpublished']
Matching and comparison
// Test page against a selector in memory (no DB query)
if($page->matches('created>=today')) { ... }
if($page->matches('template=product, featured=1')) { ... }

// Test page against a selector via database query
if($page->matchesDatabase('title=Hello')) { ... }

// Conditional output shorthand
echo $page->if('featured', '<b>Featured</b>');
echo $page->if('featured=1', '<b>Yes</b>', '<b>No</b>');
URL and path methods

The following may be accessed as methods or properties.

$page->url();     // URL path (e.g. /about/team/)
$page->path();    // like url() but without installation subdir (if applicable)
$page->httpUrl(); // with scheme+host (e.g. https://example.com/about/team/)
$page->editUrl(); // admin edit URL

// Get all URL variants (useful for language or multi-domain setups)
$urls = $page->urls();  // returns object with url, httpUrl, edit, etc.

// urlOptions used internally by traversal methods
Field introspection
// Does the page's template include this field?
if($page->hasField('body')) { ... }

// Get the Field object for a field
$field = $page->getField('body');

// Get all Field objects for this page's template
foreach($page->getFields() as $field) { echo $field->name; }
Access and permissions

The following methods are added at runtime by the PagePermissions module (installed by default). They respect the current $user and the page's access template.

if($page->viewable()) { ... }         // is page viewable by current user?
if($page->editable()) { ... }         // is page editable by current user?
if($page->publishable()) { ... }      // can current user publish this page?
if($page->listable()) { ... }         // is page listable by current user?
if($page->deleteable()) { ... }       // can current user delete this page?
if($page->trashable()) { ... }        // can current user trash this page?
if($page->addable()) { ... }          // can current user add children?
if($page->addable('product')) { ... } // can current user add a child of given template?
if($page->moveable()) { ... }         // can current user move this page?
if($page->sortable()) { ... }         // can current user change sort of this page?
if($page->cloneable()) { ... }        // can current user clone this page?

Lower-level access methods (always available):

If a page's template does not define access control then the page will inherit its access control from one of its parents. The following methods return the page that the current one inherits its access control from, whether the page itself, or a parent.

$accessTemplate = $page->getAccessTemplate();    // Template that controls access
$accessParent   = $page->getAccessParent();      // Page that provides access settings
$roles          = $page->getAccessRoles();       // WireArray of Roles with view access
if($page->hasAccessRole($role)) { ... }
Output and rendering
// Render page using its template file (returns string)
echo $page->render();

// Render a field using a site/templates/fields/ file
echo $page->renderField('body');
echo $page->renderField('images', 'gallery'); // with custom file
echo $page->render('images');                 // alias of renderField

// Render field via property syntax
echo $page->render->images;
echo $page->_images_;               // double-underscore shorthand

// Get markup for a field (uses Fieldtype::markupValue)
echo $page->getMarkup('body');

// Get plain text (applies entity decoding when output formatting on)
$text = $page->getText('body');
$text = $page->getText('body', true); // require 1-line value
$text = $page->getText('body', true, false); // 1-line value, entities off

// Front-end editable field (requires PageFrontEdit module)
echo $page->edit('body');

// getMarkup() with format string — fills {tag} placeholders from page fields
echo $page->getMarkup('{title} — {summary}');
Page references and links
// Pages that reference this page via a Page-type field
$refs = $page->references();
$refs = $page->references('template=news');     // filtered

// Pages that this page references via Page-type fields
$linking = $page->referencing();
$linking = $page->referencing('template=category');

// Pages linked from this page's text/HTML content (where possible to detect)
$linked = $page->links();
$linked = $page->links('template=product');
Preloading
// Preload one or more field values into this page (avoids repeated lazy-load queries)
$page->preload('body');
$page->preload(['body', 'images', 'sidebar']);
NullPage

When $pages->get() or traversal methods find no result, they return a NullPage rather than null. A NullPage has id === 0.

$page = $pages->get('template=product, sku=MISSING');
if($page->id) {
    // found
} else {
    // not found — $page is a NullPage
}

if($page instanceof NullPage) {
    // not found — $page is a NullPage
}

// Case where $page can be `null` or `NullPage`
if("$page") { ... } // page is not null and has id=0 (NullPage)

// Do NOT do:
if($page) { ... }      // Page object is always truthy — even NullPage
Custom page classes

To implement your own Page type, create a class file in /site/classes/ using the following format: [TemplateName]Page.php . For example:

TemplateClassFile
productProductPagesite/classes/ProductPage.php
basic-pageBasicPagePagesite/classes/BasicPagePage.php
homeHomePagesite/classes/HomePage.php
blog-postBlogPostPagesite/classes/BlogPostPage.php

The custom class should be in the ProcessWire namespace and extend Page or another class that extends Page. For example:

<?php namespace ProcessWire;

/**
 * Product Page
 *
 * @property string $title
 * @property int $qty_available
 * @property PageArray $categories
 * @property Pageimages $photos
 * @property string $body
 *
 */
class ProductPage extends Page {
    // example of custom function
    public function inStock() {
        return $this->qty_available > 0;
    }
}

When the above is implemented, all pages using the template named product will be instantiated as ProductPage instances rather than Page instances.

We recommend documenting the fields used by the template in the custom page class phpdoc header, as shown in the example above.

Note that to use custom page classes you must have the following in your /site/config.php file (enabled by default on new installations):

$config->usePageClasses = true;
Identifying page type

A page's type is typically identified by its template…

if($page->template->name === 'product') {
    // Page is a 'product' page
}

…but when using custom page classes, you can also identify a page by its class type:

if($page instanceof ProductPage) {
    // Page is a 'product' page
}
Other core page types

In addition to the Page class, the core uses Page objects for the following classes, which descend from the Page class:

ClassDescription
UserRepresents users in the system, with $user being the current user.
RoleRepresents user roles, assigned to users and templates for access control.
PermissionIndividual named permission that are assigned to Role pages.
LanguageWhen multi-language support is installed, represents a language.
Hookable page methods

Hook before or after any of these methods using $wire->addHookBefore('Page::methodName', …) or $wire->addHookAfter('Page::methodName', …). Hook the class to intercept all pages, or hook a specific instance to intercept just one page. You can also hook a custom page class to capture only instances of that page type, i.e. $wire->addHookAfter('ProductPage::added', …).

MethodDescription
getUnknown($key)Called when getting an unrecognized property; hook after and set $event->return to inject custom property values
path()Returns the page's URL path; hook after to rewrite or modify the path and url (since url uses path).
loaded()Called after the page is fully loaded from the database
editReady(InputfieldWrapper $form)Called when page is loaded into the admin page editor; hook to modify the editing form
saveReady(array $changes, $name)Called right before the page is saved; $name is a field name string when saving a single field, or false when saving the whole page
saved(array $changes, $name)Called right after the page is saved; same $name convention as saveReady
addReady()Called when a new page is about to be saved to the database for the first time
added()Called after a new page has been saved to the database for the first time
moveReady(Page $oldParent, Page $newParent)Called when the page is about to be moved to a different parent
moved(Page $oldParent, Page $newParent)Called after the page has been moved to a different parent
deleteReady()Called right before the page is permanently deleted
deleted()Called after the page has been permanently deleted
cloneReady(Page $copy)Called right before the page is cloned; $copy is the new page being created
cloned(Page $copy)Called right after the page has been cloned; $copy is the new page
renameReady(string $oldName, string $newName)Called right before the page's name is changed
renamed(string $oldName, string $newName)Called right after the page's name has been changed
addStatusReady(string $name, int $value)Called when a status flag is about to be added but not yet saved; hook before to cancel or modify
addedStatus(string $name, int $value)Called after a status flag has been added and saved
removeStatusReady(string $name, int $value)Called when a status flag is about to be removed but not yet saved; hook before to cancel or modify
removedStatus(string $name, int $value)Called after a status flag has been removed and saved

For a full list of hookable Page methods, see the phpdoc header of the Page class, or the Page hooks reference.

// Hook example
$wire->addHookAfter('Page::saved', function(HookEvent $e) {
    $page = $e->object; // Page
    $changes = $e->arguments(0); // array
    $e->wire->message(
        // i.e. "Saved product /products/my-product/ - title, categories"
        "Saved $page->template $page->url - " .
        implode(', ', $changes)
    );
}); 
Notes
  • $page->of(false) must be called before setting or saving field values; skipping it can corrupt formatted values (e.g. saving HTML-encoded entities back to the DB).
  • $page->children(), $page->find() and similar methods exclude hidden, unpublished, and inaccessible pages by default. Add include=hidden, include=unpublished, or include=all to the selector to override.
  • Status is a bitmask integer. Multiple statuses are combined with |: Page::statusHidden | Page::statusUnpublished.
  • statusCorrupted is a runtime-only flag. If present, ProcessWire refuses to save the page to protect against writing corrupt data.
  • The Page class delegates most of its method implementations to helper classes in wire/core/Page/. The main class file is wire/core/Page/Page.php.
API reference: methods, properties, hooks, constants

The $page API variable represents the current page being viewed. However, the documentation here also applies to all Page objects that you may work with in the API. We use $page as the most common example throughout the documentation, but you can substitute that with any variable name representing a Page.


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

Show $var?     Show args?       Only hookable?    

Common

NameReturnSummary 
$page->child()
Page NullPage

Return the page’s first single child that matches the given selector.


Can also be used as property: $page->child
 
$page->children()
PageArray array

Return this page’s children, optionally filtered by a selector


Can also be used as property: $page->children
 
$page->find()
PageArray

Find descendant pages matching given selector

 
$page->findOne()
Page NullPage

Find one descendant page matching given selector

 
$page->get(string $key)
mixed

Get the value of a Page property (see details for several options)

 
$page->getMultiple($keys)
array

Get multiple Page property/field values in an array

 
$page->hasChildren()
int

Return the number of visible children, optionally with conditions


Can also be used as property: $page->hasChildren
 
$page->hasFile(string $file)
bool string

Does Page have given filename in its files directory?

 
$page->hasStatus($status)
bool

Does this page have the given status?

 
$page->httpUrl()
string

Returns the URL to the page, including scheme and hostname


Can also be used as property: $page->httpUrl
 
$page->id int The numbered ID of the current page  
$page->if($key)
mixed string bool

If value is available for $key return or call $yes condition (with optional $no condition)

$page->name string The name assigned to the page, as it appears in the URL  
$page->numChildren()
int

Return number of all children, optionally with conditions


Can also be used as property: $page->numChildren
 
$page->numParents()
int

Return number of parents (depth relative to homepage) that this page has, optionally filtered by a selector


Can also be used as property: $page->numParents
 
$page->of()
bool

Get or set the current output formatting state of the page

 
$page->parent()
Page

Return this page’s parent Page, or–if given a selector–the closest matching parent.


Can also be used as property: $page->parent
 
$page->parents()
PageArray

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


Can also be used as property: $page->parents
 
$page->path()
string

Returns the Page’s path from the ProcessWire installation root.


Can also be used as property: $page->path
$page->preload()
array

Preload multiple fields together as a group (experimental)

 
$page->rootParent()
Page

Get the lowest-level, non-homepage parent of this page


Can also be used as property: $page->rootParent
$page->save()
bool

Save the entire page to the database, or just a field from it

 
$page->saveFields($fields)
array

Save only the given named fields for this page

 
$page->set(string $key, mixed $value)
Page WireData

Set the value of a page property

 
$page->template()
Template null

Get or set template


Can also be used as property: $page->template
 
$page->url()
string

Returns the URL to the page (optionally with additional $options)


Can also be used as property: $page->url
 

Traversal

NameReturnSummary 
$page->child()
Page NullPage

Return the page’s first single child that matches the given selector.


Can also be used as property: $page->child
 
$page->children()
PageArray array

Return this page’s children, optionally filtered by a selector


Can also be used as property: $page->children
 
$page->closest($selector)
Page NullPage

Find the closest parent page matching your selector

 
$page->descendant()
Page NullPageFind one descendant page, alias of Page::findOne(), see that method for details. 3.0.116
$page->descendants()
PageArrayFind descendant pages, alias of Page::find(), see that method for details. 3.0.116
$page->find()
PageArray

Find descendant pages matching given selector

 
$page->findOne()
Page NullPage

Find one descendant page matching given selector

 
$page->hasChildren()
int

Return the number of visible children, optionally with conditions


Can also be used as property: $page->hasChildren
 
$page->hasLinks int Number of visible pages (to current user) linking to this page in Textarea/HTML fields.  
$page->hasReferences int Number of visible pages (to current user) referencing this page with page reference fields.  
$page->index()
int

Return the index/position of this page relative to siblings.


Can also be used as property: $page->index
 
$page->links()
PageArray

Return pages linking to this one (in Textarea/HTML fields)


Can also be used as property: $page->links
$page->matches($s)
bool

Given a selector, return whether or not this Page matches using runtime/memory comparison

 
$page->matchesDatabase($s)
bool

Given a selector, return whether or not this Page matches by querying the database

 
$page->next()
Page NullPage

Return the next sibling page


Can also be used as property: $page->next
 
$page->nextAll()
PageArray int

Return all sibling pages after this one, optionally matching a selector

 
$page->nextUntil()
PageArray

Return all sibling pages after this one until matching the one specified

 
$page->numChildren()
int

Return number of all children, optionally with conditions


Can also be used as property: $page->numChildren
 
$page->numDescendants()
int

Return number of descendants (children, grandchildren, great-grandchildren, …), optionally with conditions


Can also be used as property: $page->numDescendants
 
$page->numLinks int Total number of pages manually linking to this page in Textarea/HTML fields.  
$page->numReferences int Total number of pages referencing this page with Page reference fields.  
$page->numReferencing int Total number of other pages this page is pointing to (referencing) with Page fields.  
$page->parent()
Page

Return this page’s parent Page, or–if given a selector–the closest matching parent.


Can also be used as property: $page->parent
 
$page->parents()
PageArray

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


Can also be used as property: $page->parents
 
$page->parentsUntil()
PageArray

Return all parents from current page till the one matched by $selector

 
$page->prev()
Page NullPage

Return the previous sibling page


Can also be used as property: $page->prev
 
$page->prevAll()
Page NullPage int

Return all sibling pages before this one, optionally matching a selector

 
$page->prevUntil()
PageArray

Return all sibling pages before this one until matching the one specified

 
$page->references()
PageArray array

Return pages that have Page reference fields pointing to this one (references)


Can also be used as property: $page->references
$page->referencing PageArray Return pages that this page is referencing by way of Page reference fields.  
$page->rootParent()
Page

Get the lowest-level, non-homepage parent of this page


Can also be used as property: $page->rootParent
$page->siblings()
PageArray

Return this Page’s sibling pages, optionally filtered by a selector.


Can also be used as property: $page->siblings
 

Manipulation

NameReturnSummary 
$page->addStatus($statusFlag)
$this

Add the specified status to this page

 
$page->addUrl($url)
boolAdd a new URL that redirects to this page and save immediately (returns false if already taken).
$page->delete()
bool int

Delete this page from the database

 
$page->isChanged()
bool

Has the Page changed since it was loaded?

 
$page->of()
bool

Get or set the current output formatting state of the page

 
$page->removeStatus($statusFlag)
$this

Remove the specified status from this page

 
$page->removeUrl($url)
boolRemove a URL that redirects to this page and save immediately.
$page->resetTrackChanges()
$this

Clears out any tracked changes and turns change tracking ON or OFF

 
$page->save()
bool

Save the entire page to the database, or just a field from it

 
$page->set(string $key, mixed $value)
Page WireData

Set the value of a page property

 
$page->setAndSave($key)
bool

Quickly set field value(s) and save to database

 
$page->setName(string $value)
$this

Set the page name, optionally for specific language

 
$page->setQuietly(string $key, mixed $value)
$this

Quietly set the value of a page property.

 
$page->status()
int array Page

Get or set current status


Can also be used as property: $page->status
 
$page->trash()
bool

Move this page to the trash

 

Date time

NameReturnSummary 
$page->created int Unix timestamp of when the page was created.  
$page->createdStr string Date/time when the page was created (formatted date/time string).  
$page->modified int Unix timestamp of when the page was last modified.  
$page->modifiedStr string Date/time when the page was last modified (formatted date/time string).  
$page->published int Unix timestamp of when the page was published.  
$page->publishedStr string Date/time when the page was published (formatted date/time string).  

Access

NameReturnSummary 
$page->addable()
boolReturns true if the current user can add children to the page, false if not. Optionally specify the page to be added for additional access checking.
Can also be used as property: $page->addable
$page->cloneable()
boolCan current user clone this page? Specify false for $recursive argument to ignore whether children are cloneable. 3.0.239
Can also be used as property: $page->cloneable
$page->deletable()
boolAlias of deleteable().
Can also be used as property: $page->deletable
$page->deleteable()
boolReturns true if the page is deleteable by the current user, false if not.
Can also be used as property: $page->deleteable
$page->editable()
boolReturns true if the page (and optionally field) is editable by the current user, false if not.
Can also be used as property: $page->editable
$page->getAccessParent()
Page NullPage

Returns the page from which role/access settings are inherited from

 
$page->getAccessRoles()
PageArray

Return Roles (PageArray) that have access to this page

 
$page->getAccessTemplate()
Template null

Returns the template from which role/access settings are inherited from

 
$page->hasAccessRole($role)
bool

Returns whether this page has the given access role

 
$page->listable()
boolReturns true if the page is listable by the current user, false if not.
Can also be used as property: $page->listable
$page->moveable()
boolReturns true if the current user can move this page. Optionally specify the new parent to check if the page is moveable to that parent.
Can also be used as property: $page->moveable
$page->publishable()
boolReturns true if the page is publishable by the current user, false if not.
Can also be used as property: $page->publishable
$page->restorable()
boolReturns true if page is in the trash and is capable of being restored to its original location. 3.0.107
$page->sortable()
boolReturns true if the current user can change the sort order of the current page (within the same parent).
Can also be used as property: $page->sortable
$page->trashable()
boolReturns true if the page is trashable by the current user, false if not.
Can also be used as property: $page->trashable
$page->viewable()
boolReturns true if the page (and optionally field) is viewable by the current user, false if not.
Can also be used as property: $page->viewable

Output rendering

NameReturnSummary 
$page->edit()
string bool mixed

Get front-end editable output for field (requires PageFrontEdit module to be installed)

$page->getPageListLabel()
string

Get label markup to use in page-list or blank to use template/page-list defaults

 
$page->of()
bool

Get or set the current output formatting state of the page

 
$page->render()
string mixed

Render output of this Page or a Field


Can also be used as property: $page->render
$page->renderField(string $fieldName)
mixed string

Render given field using site/templates/fields/ markup file

$page->renderPage()
string mixed

Render page output

$page->renderValue(mixed $value)
mixed string

Render given value using /site/templates/fields/ markup file

Status

NameReturnSummary 
$page->addStatus($statusFlag)
$this

Add the specified status to this page

 
$page->hasStatus($status)
bool

Does this page have the given status?

 
$page->is($status)
bool

Does this page have the specified status number or template name?

 
$page->isHidden()
bool

Does this page have a 'hidden' status?

 
$page->isLocked()
bool

Does this page have a 'locked' status?

 
$page->isPublished()
bool

Is this page published? (i.e. does not have 'unpublished' status)

 
$page->isTrash()
bool

Is this Page in the trash?

 
$page->isUnpublished()
bool

Does this page have a 'unpublished' status?

 
$page->removeStatus($statusFlag)
$this

Remove the specified status from this page

 
$page->status()
int array Page

Get or set current status


Can also be used as property: $page->status
 
$page->statusPrevious int null Previous status, if status was changed. Null if not.  

Constants

NameReturnSummary 
Page::statusHidden const1024Page is hidden and excluded from page finding methods unless overridden by selector (name: "hidden"). 
Page::statusIncomplete const128 
Page::statusLocked const4Indicates page is locked for changes (name: "locked") 
Page::statusUnpublished const2048Page is unpublished (not publicly visible) and excluded from page finding methods unless overridden (name: "unpublished"). 

Languages

Multi-language methods require these core modules: LanguageSupport, LanguageSupportFields, LanguageSupportPageNames.

NameReturnSummary 
$page->getLanguageName()
array stringGet page name for language(s). If given a Language object, it returns a string. If given array of language names, or argument omitted, it returns an array like [ 'default' => 'hello', 'es' => 'hola' ];. 3.0.236
$page->getLanguageStatus()
array boolGet active status for language(s). If given a $language (Language or name of language) it returns a boolean. If given multiple language names (array), or argument omitted, it returns array like [ 'default' => true, 'fr' => false ];. 3.0.236
$page->getLanguageValue($language, $field)
mixedGet value for field in language (requires LanguageSupport module). $language may be ID, language name or Language object. Field should be field name (string).
$page->getLanguageValues($field)
arrayGet values for field or one or more languages (requires LanguageSupport module). $field should be field/property name (string), $langs should be array of language names, or omit for all languages. Returns array of values indexed by language name. 3.0.236
$page->getLanguages()
PageArray null

Get languages active for this page and viewable by current user

 
$page->localHttpUrl()
stringReturn the page URL (including scheme and hostname) in the current user's language, or specify $language argument (Language object, name, or ID).
$page->localName()
stringReturn the page name in the current user’s language, or specify $language argument (Language object, name, or ID), or TRUE to use default page name when blank (instead of 2nd argument).
$page->localPath()
stringReturn the page path in the current user's language, or specify $language argument (Language object, name, or ID).
$page->localUrl()
stringReturn the page URL in the current user's language, or specify $language argument (Language object, name, or ID).
$page->setLanguageName($language)
PageSet page name for language with $page->setLanguageName('es', 'hola'); or set multiple with $page->setLanguageName([ 'default' => 'hello', 'es' => 'hola' ]); 3.0.236
$page->setLanguageStatus($language)
PageSet active status for language(s), can be called as $page->setLanguageStatus('es', true); or $page->setLanguageStatus([ 'es' => true, 'br' => false ]); to set multiple. 3.0.236
$page->setLanguageValue($language, $field, $value)
PageSet value for field in language (requires LanguageSupport module). $language may be ID, language name or Language object. Field should be field name (string).
$page->setLanguageValues($field, array $values)
PageSet value for field in one or more languages (requires LanguageSupport module). $field should be field/property name (string), $values should be array of values indexed by language name. 3.0.236

System

Most system properties directly correspond to columns in the pages database table.

NameReturnSummary 
$page->created int Unix timestamp of when the page was created.  
$page->created_users_id int ID of created user.  
$page->id int The numbered ID of the current page  
$page->modified int Unix timestamp of when the page was last modified.  
$page->modified_users_id int ID of last modified user.  
$page->name string The name assigned to the page, as it appears in the URL  
$page->parent_id int The numbered ID of the parent page or 0 if homepage or not assigned.  
$page->published int Unix timestamp of when the page was published.  
$page->sort int Sort order of this page relative to siblings (applicable when manual sorting is used).  
$page->sortPrevious int null Previous sort order, if changed 3.0.235+  
$page->sortfield()
string

Return the field name by which children are sorted


Can also be used as property: $page->sortfield
 
$page->templates_id int The numbered ID of the template usedby this page.  

Advanced

NameReturnSummary 
$page->count()
int

Returns number of children page has, affected by output formatting mode.

 
$page->draft()
ProDraft int string Page arrayHelper method for drafts (added by ProDrafts).
$page->fieldgroup Fieldgroup Fieldgroup used by page template. Shorter alias for $page->template->fieldgroup (same as $page->fields)  
$page->fields Fieldgroup All the Fields assigned to this page (via its template). Returns a Fieldgroup.  
$page->getField($field)
Field null

Get a Field object in context or NULL if not valid for this page

 
$page->getFields()
FieldsArray

Returns a FieldsArray of all Field objects in the context of this Page

 
$page->getFormatted(string $key)
mixed

Get the formatted value of a field, regardless of output formatting state

 
$page->getInputfield(string $fieldName)
Inputfield InputfieldWrapper null

Get a single Inputfield for the given field name

 
$page->getIterator()
ArrayObject

Enables iteration of the page's properties and fields with PHP’s foreach()

 
$page->getMarkup(string $key)
string

Return the markup value for a given field name or {tag} string

$page->getText(string $key)
string

Same as getMarkup() except returned value is plain text

 
$page->getUnformatted(string $key)
mixed

Get the unformatted value of a field, regardless of current output formatting state

 
$page->hasField($field)
bool string

Returns whether or not given $field name, ID or object is valid for this Page

 
$page->meta()
WireDataDB string array int float

Get or set page’s persistent meta data

 
$page->outputFormatting bool Whether output formatting is enabled or not. Same as calling $page->of() with no arguments.  
$page->setQuietly(string $key, mixed $value)
$this

Quietly set the value of a page property.

 
$page->setUnformatted(string $key, mixed $value)
self

Set the unformatted value of a field, regardless of current output formatting state

 

For hooks

These methods are only useful for hooking and should not be called directly.

NameReturnSummary 
$page->addReady()
None

Called when this new Page about to be added and saved to the database

$page->addStatusReady(string $name, int $value)
None

Called when new status flag about to be added to page but not yet saved

$page->added()
None

Called after this new Page has been added

$page->addedStatus(string $name, int $value)
None

Called when a new status flag has been added (and saved)

$page->callUnknown(string $method, array $arguments)
null mixed

If method call resulted in no handler, this hookable method is called.

$page->cloneReady(Page $copy)
None

Called right before this page is cloned

$page->cloned(Page $copy)
None

Called right after this page has been cloned

$page->deleteReady()
None

Called right before this page is deleted (and before any of its data is touched)

$page->deleted()
None

Called after this page and its data has been deleted

$page->editReady(InputfieldWrapper $form)
None

Called when this page has been loaded into the Page editor (ProcessPageEdit)

$page->getUnknown(string $key)
null mixed

Hookable method called when a request to a field was made that didn't match anything

$page->loaded()
None

Called when this page has been loaded and is now ready and use

$page->moveReady(Page $oldParent, Page $newParent)
None

Called when this Page is about to be moved to another parent

$page->moved(Page $oldParent, Page $newParent)
None

Called after this Page has been moved to another parent

$page->removeStatusReady(string $name, int $value)
None

Called when status flag is about to removed from page but not yet saved

$page->removedStatus(string $name, int $value)
None

Called when a status flag has been removed from this page (and saved)

$page->renameReady(string $oldName, string $newName)
None

Called right before this page is renamed (i.e. has its name property changed)

$page->renamed(string $oldName, string $newName)
None

Called right after this page has been renamed (i.e. had its name property changed)

$page->saveReady(array $changes)
None

Called right before this Page is saved

$page->saved(array $changes)
None

Called right after this Page is saved

Urls

NameReturnSummary 
$page->addUrl($url)
boolAdd a new URL that redirects to this page and save immediately (returns false if already taken).
$page->editUrl()
string

Return the URL necessary to edit this page


Can also be used as property: $page->editUrl
 
$page->httpUrl()
string

Returns the URL to the page, including scheme and hostname


Can also be used as property: $page->httpUrl
 
$page->localHttpUrl()
stringReturn the page URL (including scheme and hostname) in the current user's language, or specify $language argument (Language object, name, or ID).
$page->localPath()
stringReturn the page path in the current user's language, or specify $language argument (Language object, name, or ID).
$page->localUrl()
stringReturn the page URL in the current user's language, or specify $language argument (Language object, name, or ID).
$page->path()
string

Returns the Page’s path from the ProcessWire installation root.


Can also be used as property: $page->path
$page->removeUrl($url)
boolRemove a URL that redirects to this page and save immediately.
$page->url()
string

Returns the URL to the page (optionally with additional $options)


Can also be used as property: $page->url
 
$page->urls()
array

Return all URLs that this page can be accessed from (excluding URL segments and pagination)


Can also be used as property: $page->urls
 

Files

NameReturnSummary 
$page->filesManager()
PagefilesManager

Return instance of PagefilesManager specific to this Page


Can also be used as property: $page->filesManager
 
$page->filesPath()
string

Returns the path for files, creating it if it does not yet exist


Can also be used as property: $page->filesPath
 
$page->filesUrl()
string

Returns the URL for files, creating it if it does not yet exist


Can also be used as property: $page->filesUrl
 
$page->hasFiles()
bool

Does the page have a files path and one or more files present in it?


Can also be used as property: $page->hasFiles
 
$page->hasFilesPath()
bool

Does the page have a files path for storing files?

 
$page->secureFiles()
bool null

Does this Page use secure Pagefiles?

 

Previous

Provides access to the previously set runtime value of some Page properties.

NameReturnSummary 
$page->namePrevious string null Previous name, if changed. Null or blank string if not.  
$page->parentPrevious Page null Previous parent, if parent was changed. Null if not.  
$page->statusPrevious int null Previous status, if status was changed. Null if not.  
$page->templatePrevious Template null Previous template, if template was changed. Null if not.  

Properties

NameReturnSummary 
$page->title string null The page’s title (headline) text. This is a custom field but is present for most pages (null when not).  

Users

NameReturnSummary 
$page->createdUser User NullPage The user that created this page. Returns a User or a NullPage.  
$page->created_users_id int ID of created user.  
$page->modifiedUser User NullPage The user that last modified this page. Returns a User or a NullPage.  
$page->modified_users_id int ID of last modified user.  

Additional methods and properties

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

API reference based on ProcessWire core version 3.0.259