$pages
Built-in Methods Reference
$pages->find("selector") Find and return all pages matching the given selector string. Returns a filtered PageArray unless an include mode is specified. more
$pages->count("selector") Count pages matching the selector. Returned count is filtered unless an include mode is specified. more
$pages->get("selector") Get the page matching the given selector string without exclusions. Returns a Page, or a NullPage if not found. more
$pages->get(123) Get the page matching the given numeric ID, with no exclusions. Returns a Page, or a NullPage if not found. more
$pages->get("/path/to/page/") Get the page matching the given path/URL (relative to ProcessWire installation root), with no exclusions. Returns a Page, or a NullPage if not found. more
$pages->save($page) Save any changes made to the given $page. Same as: $page->save() with no arguments. more
$pages->saveField($page, 'field') Save just the named field from $page. (v2.1+) Same as: $page->save('field') more
$pages->trash($page) Move the given page to the Trash. more
$pages->delete($page) Permanently delete the given page and any attached media. Throws error when $page has children. more
$pages->delete($page, true) Recursively delete $page and all it's children and attached media, permanently. more
$pages->clone($page) Creates a brand new cloned copy of the given page (and any children) and returns it. (v2.1+) more
$pages->clone($page, $parent) Like the above, but with a new $parent page specified. (v2.1+) more
$pages->clone($page, $parent, false) Like the above, but only the given page will be cloned (and not any children). (v2.1+) more
$page
Built-in Fields Reference
$page->id The numbered ID of the current page more
$page->name The name assigned to the page, as it appears in the URL more
$page->title The page's title (headline) text more
$page->path The page's URL path from the homepage (i.e. /about/staff/ryan/) more
$page->url The page's URL path from the server's document root (may be the same as the $page->path) more
$page->httpUrl Same as $page->url, except includes protocol (http or https) and hostname. more
$page->parent The parent Page object or a NullPage if there is no parent. more
$page->parentID The numbered ID of the parent page or 0 if none. $page->parent_id also works. more
$page->parents Return this page's parent pages as Page Array. more
$page->rootParent The parent page closest to the homepage (typically used for identifying a section) more
$page->template The Template object this page is using more
$page->fields All the Fields assigned to this page (via it's template, same as $page->template->fields). Returns a FieldsArray. more
$page->numChildren The number of children (subpages) this page has. more
$page->children All the children (subpages) of this page.* Returns a filtered PageArray. See also $page->children($selector). more
$page->child The first child of this page. Returns a Page. See also $page->child($selector). more
$page->siblings All the sibling pages of this page.† Returns a PageArray. See also $page->siblings($selector). more
$page->next This page's next sibling page, or NullPage if it is the last sibling.† See also $page->next($pageArray). more
$page->prev This page's previous sibling page, or NullPage if it is the first sibling.† See also $page->prev($pageArray). more
$page->created Unix timestamp of when the page was created more
$page->modified Unix timestamp of when the page was last modified more
$page->createdUser The user that created this page. Returns a User or a NullUser. more
$page->modifiedUser The user that last modified this page. Returns a User or a NullUser. more
Built-in Methods Reference
$page->find($selector) Find pages matching the selector anywhere below this page (children, grandchildren, etc.). Returns a PageArray. more
$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 more
$page->get("field1|f2|f3") Get the first matching non-empty field by specified by a string of pipe "|" separated field names more
$page->getUnformatted("field") Get the unformatted value of the given field name. May also be used with "|" separated field names (mentioned above). more
$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. more
$page->of(true|false) This is the short notation of setOutputFormatting(). Since PW 2.2.2 more
$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.) more
$page->children($selector) Returns the filtered children (PageArray) of this page, optionally filtered by a selector. more
$page->child($selector) The first matching child (subpage) that matches the given selector. Returns a Page, or a NullPage if no match. more
$page->siblings($selector) All the sibling pages of this page, filtered by a selector.† Returns a PageArray. more
$page->parent($selector) Return this page's parent Page, or the closest parent matching the given selector. more
$page->parents($selector) Return this page's parent pages, or the parent pages matching the given selector. more
$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 more
$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. more
$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). more
$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. more
$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. more
$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). more
$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. more
$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. more
$page->save() Save this Page more
$page->save($field) Save just the field given by the provided field name (string) or object (Field) more
$page->delete() Delete this page more
$page->is($name) Returns true if this page matches the given template name, page status, or selector. more
$page->isChanged() Has the $page changed since it was loaded? Returns true or false. more
$page->isChanged("field") Has the given field on $page changed since it was loaded? Returns true or false. more
$page->isNew() Is this Page new? (i.e. doesn't yet exist in DB) more
$page->isHidden() Returns true if page has status hidden. more
$page->isTrash() Returns true if page is in trash. more
$page->matches("selector") Returns true if this page matches the given selector string. more
$page->render() Returns rendered page markup. echo $page->render(); more
$page->set("field", $value) Set the given custom field name to have the provided value. Same as $page->$field = $value; more
$page->editable() Is the page is editable by the current user? Returns true or false. more
$page->editable('field') Is the given field name is editable on the page by the current user? Returns true or false. more
$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. more
$page->addable() Is the current user allowed to create pages below this page? Returns true or false. more
$page->addable($addPage) Is the current user allowed to add the given page ($addPage) as a child of $page? Returns true or false. more
$page->moveable() Is the page allowed to be moved by the current user? Returns true or false. more
$page->moveable($parent) Is the current user allowed to move $page to $parent? Returns true or false. more
$page->sortable() Is the page sortable (within the same parent) by the current user? Returns true or false. more
$page->deleteable() Is the page deleteable by the current user? Returns true or false. more
$page->addStatus(Page::statusHidden) Add a status to this page. more
$page->removeStatus(Page::statusHidden) Removes a status from this page. more
Page Status
Page::statusOn (1) base status for all pages more
Page::statusLocked (4) page locked for changes. Not enforced by the core, but checked by Process modules. more
Page::statusSystemID (8) page is for the system and may not be deleted or have it's id changed (everything else, okay) more
Page::statusSystem (16) page is for the system and may not be deleted or have it's id, name, template or parent changed more
Page::statusHidden (1024) page is excluded selector methods like $pages->find() and $page->children() unless status is specified, like "status&1" more
Page::statusUnpublished (2048) page is not published and is not renderable. more
Page::statusTrash (8192) page is in the trash more
PageArray/WireArray
PageArray only
$a->getTotal() Get the total number of pages that were found from a $pages->find("selectors, limit=n") operation that led to this PageArray. The number returned may be greater than the number of pages actually in this PageArray instance, and is used for calculating pagination. Whereas $p->count() will always return the number of pages actually in this PageArray instance. more
$a->setTotal($n) Manually set the total number of pages in this PageArray. Used for calculating pagination. more
$a->getLimit() Get the number (n) from a "limit=n" portion of a selector that resulted in this PageArray. In pagination, this value represents the max items to display per page. If there was no limit applied, this will return 0. more
$a->setLimit($n) Set the imposed limit on this PageArray. Used for pagination. more
$a->getStart() Get the number of the starting result that led to this PageArray in pagination. Returns 0 if in the first page of results. more
$a->setStart($n) Set the 'start' limiter that resulted in this PageArray. Used in pagination. more
$a->getSelectors() Return the Selectors that led to this PageArray, or null if not set/applicable. Returns an instance of Selectors (WireArray) containing one or more Selector objects. more
Getting Items
$a[$key] Returns the value of the item at the given $key, or null if not set. more
$a->$key Return the item indexed by $key or null if not found. more
$a->get($key) Returns the value of the item at the given $key, or null if not set. more
$a->find("selector") Return all items that match the given selector, or a blank WireArray if none found.
more
$a->get("selector") Return the first item that matches the given selector, or null if not found. more
$a->getRandom() Returns a single random item from this WireArray. more
$a->findRandom($n) Get $n quantity of random elements from this WireArray. Returns a WireArray (or derived type). more
$a->findRandomTimed($n, $seed='Ymd') Get a quantity of random elements from this WireArray that always returns the same random items for the same $seed. If $seed is a string, it is considered a PHP date() string. If no $seed is provided, today's date is used to seed the random number. Meaning, the default behavior is that it returns the same random items for a period of 1 day. more
$a->slice($n) Returns a new WireArray containing a slice of items from the $n'th item to the end. more
$a->slice($n, $limit) Returns a new WireArray containing a slice of items starting from the $n'th item and including up to $limit number of items. more
$a->shift() Remove (shift) the first $item from the WireArray and return it. more
$a->pop() Pop the last item off of the WireArray and return it. more
$a->index($n) Returns a new WireArray containing the item at the given zero-based index. more
$a->eq($n) Returns the single item at the given zero-based index, or NULL if it doesn't exist. more
$a->first() Returns the first item in the WireArray. more
$a->last() Returns the last item in the WireArray. more
$a->getNext($item) Given an item already in the WireArray, return the item that comes after it in this WireArray or NULL if no match. more
$a->getPrev($item) Given an item already in the WireArray, return the item that comes before it in this WireArray or NULL if no match. more
$a->getArray() Returns a regular PHP array of all items in this WireArray. more
$a->getKeys() Returns a regular PHP array of all keys used in this WireArray. more
$a->getValues() Returns a regular PHP array of all values used in this WireArray. more
$a->unique() Return a new WireArray that is the same as $a but with no duplicate values. more
$a->implode([$delim], $key) Implode all elements to a delimiter-separated string containing the given key/property from each item. Similar to PHP's implode() function.
more
$a->explode($key) Return a plain array of the requested key/property from each item. Similar to PHP's explode() function. more
$a->and($item | $items) Return a new copy of the WireArray with the given item or items appended. more
Sorting and Filtering
$a->shuffle() Randomize the order of all the items in the WireArray. more
$a->sort("property") Sorts the WireArray by the given item property (string). You may also specify the property as "property.subproperty", where property resolves to a Wire derived object, and subproperty resolves to a property within that object. Prepend a minus sign "-" to the property name reverse the sort. more
$a->filter("selector") Reduce the WireArray so that it only contains items that match the given selector. more
$a->not("selector") Reduce the WireArray so that it only contains items that don't match the given selector. more
$a->reverse() Return a new WireArray containing the items in reverse order. more
Setting and modifying items
$a[] = $item Add the given $item. more
$a->add($item) Add the given $item. Supports import of page arrays (since 2.2) more
$a[$key] = $item Add the given $item, associating it with index $key. more
$a->set($key, $item) Add the given $item, associating it with index $key. more
$a->$key = $item Add the given $item, associating it with index $key. more
$a->import($items) Given an array or WireArray of items, add them all. more
$a->prepend($item) Prepend the given item to the beginning of the WireArray. more
$a->append($item) Append the given item to the end of the WireArray. more
$a->insertBefore($item, $existingItem) Insert an item (int|string|array|object) before an existing item (int|string|array|object) more
$a->insertAfter($item, $existingItem) Insert an item (int|string|array|object) after an existing item (int|string|array|object) more
$a->unshift($item) Prepend the given item to the beginning of the WireArray (same as prepend) more
$a->shift() Remove (shift) the first $item from the WireArray and return it. more
$a->push($item) Push the given item onto the end of the WireArray. more
$a->pop() Pop the last item off of the WireArray and return it. more
unset($array[$key]) Removes the item with the given $key from the WireArray. more
$a->remove($key) Removes the item with the given $key from the WireArray. more
$a->remove($item) Removes the given $item from the WireArray. more
$a->removeAll() Removes all items from the WireArray. more
$a->replace($itemA, $itemB) Replace one item with the other. If both items are already present, they will change places. If one item is not already present, it will replace the one that is. If neither item is present, both will be added at the end. more
Checking for items
$a->count() Returns the number of items in this WireArray. more
count($a) Returns the number of items in this WireArray. more
$a->has($key) Is the given key part of this WireArray? more
$a->has("selector") Does the given selector match any items in this WireArray? more
$a->has($object) Is $object in the WireArray? $object must be an valid type of the WireArray. more
isset($a[$key]) Returns true if the given $key is set with an item. more
$a->isValidItem($item) Is the given item a valid type for this WireArray? more
$a->isValidKey($key) Is the given $key valid to use for this WireArray? more
$a->getItemKey($item) Get the key used by $item or NULL if not available. more
Change Tracking
$a->setTrackChanges() Turn on change tracking more
$a->setTrackChanges(false) Turn change tracking OFF more
$a->resetTrackChanges() Reset any changes that have been tracked and start tracking again. more
$a->resetTrackChanges(false) Reset any changes that have been tracked and stop tracking. more
$a->isChanged() Has this object changed since tracking was turned on? more
$a->getChanges() Return an array of item keys that have changed while change tracking was on. more
$a->getItemsAdded() Return an array of items that have been added since change tracking was turned on. more
$a->getItemsRemoved() Return an array of items that have been removed since change tracking was turned on. more
Files
Page Files Multiple (WireArray)
$files->path Returns the full server disk path where files are stored more
$files->url Returns the URL where files are stored more
$files->page Returns the $page that contains this set of files more
$files->delete($file) Removes the file and deletes from disk when page is saved (alias of remove) more
$files->deleteAll() Removes all items and deletes them from disk when page is saved @advanced more
$file Properties
$file->url URL to the file on the server more
$file->httpUrl Return the web accessible URL (with schema and hostname) to this Pagefile more
$file->filename full disk path to the file on the server more
$file->name Returns the filename without the path (basename) more
$file->description value of the file's description field (text). Note you can set this property directly more
$file->ext file's extension (i.e. last 3 or so characters) more
$file->filesize file size, number of bytes more
$file->filesizeStr file size as a formatted string more
(string) $file returns the file's name (no path) more
$file->pagefiles the $files array that contains this file more
$file->page the $page that contains this file more
$file Methods
$file->rename($name) Rename this file to the given name (no path). Returns true on success, false on failure. more
$file->getNext() Returns the next file in a multi-file field, or NULL if at the end more
$file->getPrev() Returns the previous file in a multi-file field, or NULL if at the beginning more
$image Properties (in addition to those in $file)
$image->width Width of image, in pixels more
$image->height Height of image, in pixels more
$image->original Reference to original $image, if this is a resized version. more
$image Methods
$image->size($width, $height, $options) Return a new $image with the given dimensions. By default it will get upscaled and center cropped with a quality of 90%. To resize and keep proportions you can 0 for height or width value. As third argument you can pass an array to overwrite the default settings: $defaultOptions = array( 'upscaling' => true, 'cropping' => true, 'quality' => 90 ); more
$image->width($width) Return a new $image with the given width (proportional height, center crop) more
$image->height($height) Return a new $image with the given height (proportional width, center crop) more
$image->getVariations() Returns a WireArray (Pageimages) of all size variations of this image more
$image->removeVariations() Deletes all size variations of this image (be careful) more
$templates
Methods
$templates->find("selector") Return the templates matching the given selector query. more
$templates->get("name") Return the template with the given name more
$templates->save($template) Save the given template instance. more
$templates->delete($template) Delete the given template instance. Note that this will throw a fatal error if the template is in use by any pages. more
Template Properties
$template->id Get or set the template's numbered database ID. more
$template->name Get or set the template's name. more
$template->filename Get or set a template's filename, including path (this is auto-generated from the name, though you may modify it at runtime if it suits your need). more
$template->label Optional short text label to describe Template. more
$template->fieldgroup Get or set a template's Fieldgroup. Can also be used to iterate a template's fields. more
$template->fields Syntactical alias for $template->fieldgroup. Use whatever makes more sense for your code readability. more
$template->cacheTime Get or set the number of seconds this template's output should be cached (default is 0). more
$template->childrenTemplatesID Get or set the template database ID that children of pages using this template default to. 0 is the default and indicates no selection. Set to -1 to disallow pages using this template from having children. more
$template->allowPageNum Get or set whether pages using this template can have URL-based page numbers. Set to 1 for yes or 0 for no. Default is 0. more
$template->urlSegments Get or set whether pages using this template can make use of URL segments. Set to 1 for yes or 0 for no. Default is 0. more
$template->slashUrls Get or set whether pages using this template should have URLs that end with a slash. Set to 1 for yes or 0 for no. Default is 1. more
$template->redirectLogin Get or set what should happen when a user attempts access to a page using this template, and they don't have access to. Set to 0 to show the 404 page, or 1 to redirect to the login page. Default is 0. more
$template->protocol Get or set what protocol is required to access pages using this template. If the user attempts access from the wrong protocol, it will be redirected to the right protocol. Set to 0 to allow either HTTP or HTTPS. Set to 1 to allow HTTPS only. Set to -1 to allow HTTP only. Default is 0. more
Template Methods
$template->get($property) Get the value of a template's property (same as $template->$property) more
$template->set($property, $value) Set the value of a template's property (same as $template->$property = $value). more
$template->getNumPages() Return the number of pages using this template. more
$template->hasField(string|int|Field) Does this template have the given field? more
$template->save() Save this template to the database. more
$fields
Fields Methods
$fields->find("selector") Find all fields matching the given selector more
$fields->get("name") Get the field specified by the given field name more
$fields->get(123) Get the field specified by the given field ID (integer) more
$fields->get("selector") Get the first matching field specified by the given selector more
$fields->save($field) Save the given Field object more
$fields->delete($field) Delete the given Field object more
Field Properties
(string) $field Casting a Field as a string returns the field's name more
$field->id Numeric ID of this field more
$field->name Name of this field (name string) more
$field->label Text label for this field, appears as the
$field->type The type of field, refers to a Fieldtype plugin module more
$field->flags Bitwise flags of the field: if($field->flags & Field::flagAutojoin) // field has the "autojoin" flag set if($field->flags & Field::flagGlobal) // field has the "global" flag set. more
Field Methods
$field->get($key) Get a field property (the properties above, or a custom property) Same as $field->$key more
$field->set($key, $value) Set a field property. Can be any one of the above or something else for a custom setting. Same as $field->$key = $value more
$field->save() Save this field. Same as $fields->save($field) more
$field->numFieldgroups() Returns the number of fieldgroups that use this field more
$field->getFieldgroups() Returns an array of fieldgroups that use this field more
$field->getTable() Returns the name of the database table created by this field more
$field->getInputfield($page) Returns an Inputfield object associated with this field for use on $page more
$users
Users Methods
$users->find("selector") Find user(s) matching given selector. more
$users->get(name|id|selector) Get user by given name, numeric ID or a selector string. more
$users->add("name") Add new User with the given name and return it. more
$users->save($user) Save given user. $user must be valid user object. more
$users->delete($user) Delete given user. $user must be valid user object. more
$user
User Properties
$user->id Numeric ID of this user more
$user->name Get or set the user's login name. more
$user->email Get or set email address for this user. more
$user->pass The user's hashed password. Note that this returns a hashed version of the password, so it is not typically useful to get this property. However, it is useful to set this property if you want to change the password. When you change a password, it is assumed to be the non-hashed/non-encrypted version. ProcessWire will hash it automatically when the user is saved. more
$user->roles Get roles this user has. Returns PageArray. more
User Methods
$user->isGuest() Is this the Guest user? Returns true or false. more
$user->isSuperuser() Is this the Superuser? Returns true or false. more
$user->isLoggedin() Is this user logged in? Returns true or false. more
$user->get($property) Get a property value from the user. Same as $user->[property]. more
$user->set($property, $value) Set a property value. Same as $user->[property] = $value; more
$user->save() Save user to the database. more
$user->hasRole($role) Does the user have the given role? Returns true or false. more
$user->addRole($role) Add the given Role to this user. more
$user->removeRole($role) Remove a given Role from this user. more
$user->hasPermission($permission) Does the user have the given permission? Returns true or false. more
$user->hasPermission($permission, $page) Does the user have the given permission name on $page? Returns true or false. more
$roles
Roles Methods
$roles->find("selector") Find roles with given selector more
$roles->get(name|id) Get role with given name or id more
$roles->add("name") Add new Role with the given name and return it. more
$roles->save($role) Save given role. $roles must be an instance of Role. more
$roles->delete($role) Delete given role. $roles must be an instance of Role. more
Role Properties
$role->id Get Numeric ID of this role. more
$role->name Get or set name (string) of this role. more
$role->permissions PageArray of permissions assigned to Role. more
Role Methods
$role->get($key) Get property value by key more
$role->save() Saves the role more
$role->hasPermission(name|id|Permission) Does this role have the given permission? more
$role->addPermission(name|id|Permission) Add the given permission. This is the same as $role->permissions->add($permission) except this one will accept name, ID or Permission. more
$role->removePermission(name|id|Permission) Remove the given permission. This is the same as $role->permissions->remove($permission) except this one will accept name, ID or Permission. more
Selectors
Built-In Page Selector Properties
any_field=any_value Match any of your own fields using any operator and any value. more
limit=n Limit the results to n Number more
sort=field Sort by a field. This may any field. Use "-" prefix to reverse sorting. sort=-field more
parent=id Page parent using ID more
parent=$page Page parent using an page object more
parent=/path/to/page/ Page parent using path more
has_parent=$page Limit to a certain parent (recursively all children). Only one parent can be used at a time. more
has_parent=id Limit to a certain parent (recursively all children). Only one parent can be used at a time. more
has_parent=/path/to/page/ Limit to a certain parent (recursively all children). Only one parent can be used at a time. more
path=/path/to/page/ Get Page with the path specified more
template=name Limit to a certain template. Use "|" to have multiple OR's. template=name|name more
template=$template You can also use a template object to compare more
start=n Set start offset more
end=n Set end offset (may be used instead of limit=n) more
include=all Include all hidden and unpublished pages and pages that user doesn't have access to view. more
include=hidden Include hidden pages in queries. more
check_access=0 Include pages that user doesn't have access to view. more
children.count=n Pages with a certain count of children may also be used with greater than / less than operators. more
created=timestamp Usually used with < > to compare timestamps more
modified=timestamp Usually used with < > to compare timestamps more
created_users_id=int Pages created with specified user id. more
modified_users_id=int Pages modified with specified user id. more
Selector Operators
= Equal to (any_field=any_value)
more
!= Not equal to (any_field!=any_value)
more
< Less than (any_field
> Greater than
any_field>any_value more
<= Less than or equal to (any_field<=any_value) more
>= Greater than or equal to (any_field>=any_value) more
*= Contains the exact word or phrase (any_field*=any_value) more
~= Contains all the words (any_field~=any_value) more
%= Contains the exact word or phrase (using slower SQL LIKE) [v2.1] (any_field%=any_value) more
^= Contains the exact word or phrase at the beginning of the field [v2.1] (any_field^=any_value) more
$= Contains the exact word or phrase at the end of the field [v2.1] (any_field$=any_value) more
$input
Properties and Methods
$input->get Provides access to GET variables more
$input->get->name Access as object property more
$input->get["name"] Access as array index more
$input->get("name") Access as function more
$input->post Provides access to POST variables more
$input->post->name Access as object property more
$input->post["name"] Access as array index more
$input->post("name") Access as function more
$input->cookie Provides access to your COOKIE variables more
$input->cookie->name Access as object property more
$input->cookie["name"] Access as array index more
$input->cookie("name") Access as function more
$input->whitelist($key, $value) Set a whitelist value more
$input->whitelist($key) Get a whitelist value more
$input->urlSegments Retrieve all URL segments (array). This requires url segments are enabled on the template of the requested page. You can turn it on or off under the url tab when editing a template. more
$input->urlSegment($n) Retrieve the $n'th URL segment (integer).
urlSegment(1) = /page/aaa/
urlSegment(2) = /page/aaa/bbb/
urlSegment(3) = /page/aaa/bbb/ccc/
...
The maximum segments allowed can be adjusted in your sites config.php.
Alternative syntax:
$input->urlSegment1
$input->urlSegment2
$input->urlSegment3
... more
$input->urlSegment1 (2,3,..) Retrieve the $n'th URL segment. Alternative syntax. The maximum segments allowed can be adjusted in your sites config.php. more
$input->pageNum Returns the current page number from the URL (1–999) more
$sanitizer
Properties and Methods
$sanitizer->email($value) Sanitizes a value for an email address, then filters it. If not valid after sanitization, this function returns a blank string. more
$sanitizer->fieldName($value) Sanitizes a value for a Field name. Same as the name() filter, except that it doesn't allow dashes. more
$sanitizer->name($value) Sanitizes a value for a ProcessWire name, meaning all characters except for these ASCII characters: "a-zA-Z0-9_." (not including the quotes) are removed. It also truncates the length to 128 characters. more
$sanitizer->pageName($value) Sanitizes a value for a URL friendly Page name. Same as the name() filter, except that it converts uppercase to lowercase, and it attempts UTF-8 to ASCII conversion. more
$sanitizer->pageName($value, true) Sanitizes a value for a URL friendly Page name and cleans out leading or trailing dashes, and converts double dashes to single dashes. Use this if you are passing in a headline to convert to a page name (for example).
If second parameter is "Sanitizer::translate" it will use the language char conversion defined in InputfieldPageName module settings. more
$sanitizer->selectorField($value) Sanitizes a field name as used in a selector value. This function is only necessary if you are dealing with user submitted field names. This is rarely the case in the author's experience, but provided here for consistency with selectorValue() more
$sanitizer->selectorValue($value) Sanitizes a string that needs to appear in a selector value. Replaces disallowed characters with spaces. If value is not already quoted, it will add quotes if it determines they are necessary (like if it contains commas). It limits the length to 100 characters (multibyte safe). more
$sanitizer->text($value) Sanitize a single line of input text. Removes tags, removes newline characters, and truncates length to 1024 characters. This is multibyte safe if your PHP has multibyte support. more
$sanitizer->text($value, $options) Same as the above, except you may provide an $options array to change the behavior. You may specify one or more options in the $options array. See the reference of $options later in this page. more
$sanitizer->textarea($value) Same as the text() function above, except that multiple lines are allowed and maxLength is 16k. more
$sanitizer->textarea($value, $options) Same as textarea() except that you may modify the options documented later in this page, noting that multiLine is already true, and maxLength is already 16384. more
$sanitizer->url($value) Filters a URL value. Returns a valid URL or blank if it can't be made valid. If URL contains a domain and is valid but missing a protocol (like http://) it will add it. It won't add a protocol to local/relative URLs. more
$sanitizer->username($value) Sanitizes a value for a User name, meaning all characters except for these ASCII characters "a-zA-Z0-9-_.@" (not including the quotes) are removed. It also truncates the length to 50 characters.
Deprecated since 2.4 uses sanitizer pageName(). more
$options $options = array(
// set to true to allow multiple lines
'multiLine' => false,
// maximum allowed characters for multibyte strings
'maxLength' => 255,
// maximum number of bytes allowed in the string (multibyte safe)
'maxBytes' => 1024,
// markup tags that are allowed. Example: "<br/><strong>"
'allowableTags' => '',
// character set of $value provided
'inCharset' => 'UTF-8',
// character set to convert to (if different from inCharset)
'outCharset' => 'UTF-8'
); more
$session
Properties and Methods
$session->set($name, $value) Set the session variable $name to have the value $value more
$session->get($name) Get the session variable identified by the string $name more
$session->$name = $value Alternate syntax for $session->set($name, $value) more
$value = $session->$name Alternate syntax for $session->get($name) more
$session->getAll() Return all set session variables in an array more
$session->remove($name) Remove/unset the session variable identified by the string $name more
$session->login($name, $pass) Login the user identified by $name and authenticated by $pass. Returns the user object on successful login or null on failure. more
$session->logout() Logout the current user session more
$session->redirect($url) Send an HTTP 301 (permanent) redirect to the specified URL more
$session->redirect($url, false) Send an HTTP 302 (temporary) redirect to the specified URL more
$config
Runtime Configuration
$config->ajax If the current request is an ajax (asynchronous javascript) request, this is set to true. more
$config->httpHost Current HTTP host name. more
$config->https If the current request is an HTTPS request, this is set to true. more
$config->version Current ProcessWire version string (i.e. "2.1.0") more
$config->styles Array used by ProcessWire admin to keep track of what stylesheet files it's template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. more
$config->scripts Array used by ProcessWire admin to keep track of what javascript files it's template should load. It will be blank otherwise. Feel free to use it for the same purpose in your own sites. more
Urls
$config->urls->root URL to your site root (homepage) in ProcessWire. more
$config->urls->templates URL to your site templates directory. more
$config->urls->admin URL to your admin control panel. more
$config->urls->adminTemplates URL to ProcessWire's admin templates directory. more
$config->urls->modules URL to ProcessWire's core modules directory. more
$config->urls->siteModules URL to your site modules directory. more
$config->urls->core URL to ProcessWire's core directory. more
$config->urls->assets URL to ProcessWire's assets directory where site-specific files, caches and logs are kept. more
$config->urls->files URL to ProcessWire's files directory, where page-specific files are kept in page ID numbered directories. more
Paths
$config->paths->root Path to your site root directory in ProcessWire. more
$config->paths->templates Path to your site templates directory. more
$config->paths->adminTemplates Path to ProcessWire's admin templates directory. more
$config->paths->modules Path to your core modules directory. more
$config->paths->siteModules Path to your site-specific modules directory. more
$config->paths->core Path to ProcessWire's core directory. more
$config->paths->assets Path to ProcessWire's assets directory where site-specific files, caches and logs are kept. more
$config->paths->files Path to ProcessWire's files directory, where page-specific files are kept in page ID numbered directories. more
$config->paths->cache Path to ProcessWire's cache directory. more
$config->paths->logs Path to ProcessWire's logs directory. more
$config->paths->sessions Path to ProcessWire's session storage directory. more
System Configuration
Date and Time
$config->dateFormat Default system date format as used by ProcessWire admin. Preferably in a format that is string sortable. This should be a PHP date() string. Default value is 'Y-m-d H:i:s'. more
$config->timezone Current timezone. Must be one of the PHP timezone options. Default value is 'America/New_York'. more
Session
$config->sessionName Session name as used in session cookie. Default is 'wire'. more
$config->sessionExpireSeconds How many seconds of inactivity before session expires. Default is 86400. more
$config->sessionChallenge Should login sessions have a challenge key? (for extra security, recommended). Default is true. more
$config->sessionFingerprint Should login sessions be tied to IP and user agent? More secure, but will conflict with dynamic IPs. Default is true. more
File creation and identification
$config->chmodDir Octal string permissions assigned to directories created by ProcessWire. Default is "0777". more
$config->chmodFile Octal string permissions assigned to files created by ProcessWire. Default is "0666". more
$config->templateExtension Expected extension for template files. Default is "php". more
$config->uploadUnzipCommand Shell command to unzip archives, used by WireUpload class. If unzip doesn't work, you may need to precede 'unzip' with a path. Default is: unzip -j -qq -n /src/ -x __MACOSX .* -d /dst/ more
$config->uploadBadExtensions File extensions that are always disallowed from uploads. Default is: php php3 phtml exe cfm shtml asp pl cgi sh vbs jsp more
Mode
$config->debug Debug mode causes additional info to appear for use during dev and debugging. Set this to true temporarily if you get a blank screen or untelligible error. Do not leave this set at true with a live site. Default is false. more
$config->advanced Turns on additional options in ProcessWire for use during ProcessWire core and/or module development. Default is false. more
$config->demo Demo Mode - Disables save functions in Process admin modules. Default is false. more
MySQL Database
$config->dbHost Database hostname more
$config->dbName Database name more
$config->dbUser Database user more
$config->dbPass Password for database user more
$config->dbPort Database port. Default is 3306. more
$config->dbCharset Database character set. Default is 'utf8'. more
$config->dbSocket Optional DB socket config for sites that need it (for most you should exclude this).tions in Process admin modules. Default is false. more
Authentication
$config->userAuthHashType Hash method to use for passwords. typically 'md5' or 'sha1'. Can be any available with your PHP's hash() installation. For instance, you may prefer to use something like sha256 if supported by your PHP installation. Default is 'sha1'. more
$config->userAuthSalt Generated automatically at installation time. A random salt string that is used in generating password hashes. A unique account-specific hash is also used. more
Pagination
$config->pageNumUrlPrefix Prefix to use in page URLs for page numbers, i.e. a prefix of 'page' would use 'page1', 'page2', etc. Default is 'page'. more
$config->adminEmail Optional e-mail address to send fatal error notifications to. more
System IDs
$config->adminRootPageID Page ID of the admin control panel home. more
$config->trashPageID Page ID of the trash page. more
$config->loginPageID Page ID of the admin login page. more
$config->http404PageID Page ID of the 404 page. more
$config->usersPageID Page ID of the users parent page. more
$config->rolesPageID Page ID of the roles parent page. more
$config->permissionsPageID Page ID of the permissions parent page. more
$config->guestUserPageID Page ID of the guest user account. more
$config->superUserPageID Page ID of the superuser account. more
$config->guestUserRolePageID Page ID of the guest role. more
$config->superUserRolePageID Page ID of the superuser role. more
$config->userTemplateID Template ID of the system 'user' template. more
$config->roleTemplateID Template ID of the system 'role' template. more
$config->permissionTemplateID Template ID of the system 'permission' template. more
Bootstrap / System
Global Namespace Wire
wire('pages')->get("/about/contact/") wire() function provides access to all of ProcessWire's API variables, like $page, $pages, $templates and others... i.e. wire('pages')->find('selector'); more