Pages Editor
Implements page editing and manipulation methods for the $pages API variable.
Please always use $pages->method()
rather than $pages->editor->method()
in cases where there is overlap.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the PagesEditor
class also inherits all the methods and properties of: Wire.
Add
Name | Return | Summary | |
---|---|---|---|
$pages->editor->add() $pages->editor->add($template, $parent) $pages->editor->add($template, $parent, string $name = '', array $values = []) | Page | Add a new page using the given template to the given parent | |
$pages->editor->setupNew() $pages->editor->setupNew(Page $page) $pages->editor->setupNew(Page $page) | None | Auto-populate some fields for a new page that does not yet exist | |
$pages->editor->setupPageName() $pages->editor->setupPageName(Page $page) $pages->editor->setupPageName(Page $page, array $options = []) | string | Auto-assign a page name to gven page |
Save
Name | Return | Summary | |
---|---|---|---|
$pages->editor->save() $pages->editor->save(Page $page) $pages->editor->save(Page $page, array $options = []) | bool | Save a page object and it's fields to database. | |
$pages->editor->saveField() $pages->editor->saveField(Page $page, $field) $pages->editor->saveField(Page $page, $field, $options = []) | bool | Save just a field from the given page | |
$pages->editor->saveFields() $pages->editor->saveFields(Page $page, $fields) $pages->editor->saveFields(Page $page, $fields, array $options = []) | array | Save multiple named fields from given page | |
$pages->editor->touch() $pages->editor->touch($pages) $pages->editor->touch($pages, $options = null, string $type = 'modified') | bool | Update page modified/created/published time to now (or given time) |
Delete
Name | Return | Summary | |
---|---|---|---|
$pages->editor->clear() $pages->editor->clear(Page $page) $pages->editor->clear(Page $page, array $options = []) | bool | Clear a page of its data | |
$pages->editor->delete() $pages->editor->delete(Page $page) $pages->editor->delete(Page $page, $recursive = false, array $options = []) | bool int | Permanently delete a page and its fields. |
Info
Name | Return | Summary | |
---|---|---|---|
$pages->editor->isCloning() $pages->editor->isCloning() $pages->editor->isCloning(bool $getDepth = false) | bool int | Are we currently in a page clone? | |
$pages->editor->isDeleteable() $pages->editor->isDeleteable(Page $page) $pages->editor->isDeleteable(Page $page, bool $throw = false) | bool | Is the given page deleteable from the API? | |
$pages->editor->isMoveable() $pages->editor->isMoveable(Page $page, Page $oldParent, Page $newParent, string $reason) $pages->editor->isMoveable(Page $page, Page $oldParent, Page $newParent, string $reason) | bool | Return whether given Page is moveable from $oldParent to $newParent | |
$pages->editor->isSaveable() $pages->editor->isSaveable(Page $page, string $reason) $pages->editor->isSaveable(Page $page, string $reason, $fieldName = '', array $options = []) | bool | Is the given page in a state where it can be saved from the API? |
Order
Name | Return | Summary | |
---|---|---|---|
$pages->editor->insertBefore() $pages->editor->insertBefore(Page $page, Page $sibling) $pages->editor->insertBefore(Page $page, Page $sibling, bool $after = false) | None | Sort one page before another (for pages using manual sort) | |
$pages->editor->move() $pages->editor->move(Page $child, $parent) $pages->editor->move(Page $child, $parent, array $options = []) | bool | Move page to specified parent (work in progress) | |
$pages->editor->sortPage() $pages->editor->sortPage(Page $page) $pages->editor->sortPage(Page $page, $sort = null, bool $after = false) | int | Set page $sort value and increment siblings having same or greater sort value | |
$pages->editor->sortRebuild() $pages->editor->sortRebuild(Page $parent) $pages->editor->sortRebuild(Page $parent) | int | Rebuild the “sort” values for all children of the given $parent page, fixing duplicates and gaps |
Status
Name | Return | Summary | |
---|---|---|---|
$pages->editor->addStatus() $pages->editor->addStatus(Page $page, int $status) $pages->editor->addStatus(Page $page, int $status) | bool | Silently add status flag to a Page and save | |
$pages->editor->removeStatus() $pages->editor->removeStatus(Page $page, int $status) $pages->editor->removeStatus(Page $page, int $status) | bool | Silently remove status flag from a Page and save | |
$pages->editor->savePageStatus() $pages->editor->savePageStatus($pageID, int $status) $pages->editor->savePageStatus($pageID, int $status, bool $recursive = false, $remove = false) | int | Add or remove a Page status and commit to DB, optionally recursive with the children, grandchildren, and so on. | |
$pages->editor->saveStatus() $pages->editor->saveStatus(Page $page) $pages->editor->saveStatus(Page $page) | bool | Silently save whatever the given Page’s status currently is |
Additional methods and properties
In addition to the methods and properties above, PagesEditor also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.252