Provides a version control API for pages in ProcessWire.
// Note: API provided by $pagesVersions API variable
// present with PagesVersions module is installed.
// Get page and add a new version of it
$page = $pages->get(1234);
$page->title = 'New title';
$version = $pagesVersions->addPageVersion($page);
echo $version; // i.e. "2"
// Get version 2 of a page
$pageV2 = $pagesVersions->getPageVersion($page, 2);
// Update a version of a page
$pageV2->title = "Updated title";
$pagesVersions->savePageVersion($pageV2);
// Restore version to live page
$pagesVersions->restorePageVersion($pageV2);
// Delete page version
$pagesVersions->deletePageVersion($pageV2);
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Pages
class also inherits all the methods and properties of: Wire.
Getting
Info
Name | Return | Summary | |
---|---|---|---|
$pagesVersions->getPageVersionInfo() $pagesVersions->getPageVersionInfo(Page $page, int $version) $pagesVersions->getPageVersionInfo(Page $page, int $version) | PageVersionInfo null | Get info for given page and version | |
$pagesVersions->getPageVersionInfos() $pagesVersions->getPageVersionInfos(Page $page) $pagesVersions->getPageVersionInfos(Page $page, array $options = []) | PageVersionInfo | Get just PageVersionInfo objects for all versions of given page | |
$pagesVersions->hasPageVersion() $pagesVersions->hasPageVersion(Page $page) $pagesVersions->hasPageVersion(Page $page, $version = 0) | bool int | Does page have the given version? | |
$pagesVersions->hasPageVersions() $pagesVersions->hasPageVersions(Page $page) $pagesVersions->hasPageVersions(Page $page) | int | Return quantity of versions available for given page |
Saving
Name | Return | Summary | |
---|---|---|---|
$pagesVersions->addPageVersion() $pagesVersions->addPageVersion(Page $page) $pagesVersions->addPageVersion(Page $page, array $options = []) | int | Add a new page version and return the added version number | |
$pagesVersions->restorePageVersion() $pagesVersions->restorePageVersion(Page $page) $pagesVersions->restorePageVersion(Page $page, int $version = 0, array $options = []) | Page bool | Restore a page version to be the live version | |
$pagesVersions->savePageVersion() $pagesVersions->savePageVersion(Page $page) $pagesVersions->savePageVersion(Page $page, $version = 0, array $options = []) | int array | Save a page version |
Deleting
Name | Return | Summary | |
---|---|---|---|
$pagesVersions->deleteAllPageVersions() $pagesVersions->deleteAllPageVersions(Page $page) $pagesVersions->deleteAllPageVersions(Page $page) | int | Delete all versions for given page | |
$pagesVersions->deleteAllVersions() $pagesVersions->deleteAllVersions() $pagesVersions->deleteAllVersions(bool $areYouSure = false) | int | Delete all versions across all pages | |
$pagesVersions->deletePageVersion() $pagesVersions->deletePageVersion(Page $page) $pagesVersions->deletePageVersion(Page $page, int $version = 0) | int | Delete specific page version |
Utility
Name | Return | Summary | |
---|---|---|---|
$pagesVersions->allowPageVersions() $pagesVersions->allowPageVersions(Page $page) $pagesVersions->allowPageVersions(Page $page) | bool | Is given page allowed to have versions? | |
$pagesVersions->getNextPageVersionNumber() $pagesVersions->getNextPageVersionNumber(Page $page) $pagesVersions->getNextPageVersionNumber(Page $page) | int | Get next available version number for given page | |
$pagesVersions->getUnsupportedFields() $pagesVersions->getUnsupportedFields() $pagesVersions->getUnsupportedFields($page = null) | Field | Get fields where versions are not supported | |
$pagesVersions->pageVersionNumber() $pagesVersions->pageVersionNumber(Page $page) $pagesVersions->pageVersionNumber(Page $page, $version = 0) | int | Get the version number of given page or 0 if not versioned |
For hooks
These methods are only useful for hooking and should not be called directly.
Name | Return | Summary | |
---|---|---|---|
$pagesVersions->allowPageVersions() $pagesVersions->allowPageVersions(Page $page) $pagesVersions->allowPageVersions(Page $page) | bool | Is given page allowed to have versions? |
Additional methods and properties
In addition to the methods and properties above, Pages
API reference based on ProcessWire core version 3.0.236