Overview

Namespaces

  • None
  • PHP

Classes

  • Breadcrumb
  • Breadcrumbs
  • CacheFile
  • Comment
  • CommentArray
  • CommentFilter
  • CommentForm
  • CommentList
  • Config
  • Database
  • DatabaseQuery
  • DatabaseQuerySelect
  • DatabaseQuerySelectFulltext
  • DatabaseStopwords
  • Debug
  • Field
  • Fieldgroup
  • Fieldgroups
  • FieldgroupsArray
  • Fields
  • FieldsArray
  • Fieldtype
  • FieldtypeMulti
  • Fieldtypes
  • FileLog
  • FilenameArray
  • Fuel
  • HookEvent
  • ImageSizer
  • Inputfield
  • InputfieldsArray
  • InputfieldWrapper
  • Language
  • LanguageParser
  • Languages
  • LanguagesPageFieldValue
  • LanguageSupportInstall
  • LanguageTranslator
  • Markdown_Parser
  • MarkdownExtra_Parser
  • ModuleJS
  • ModulePlaceholder
  • Modules
  • Notice
  • NoticeError
  • NoticeMessage
  • Notices
  • NullPage
  • Page
  • PageArray
  • Pagefile
  • Pagefiles
  • PagefilesManager
  • PageFinder
  • Pageimage
  • Pageimages
  • PagerNav
  • PagerNavItem
  • Pages
  • PagesAccess
  • PagesSortfields
  • PagesType
  • Paths
  • Permission
  • Permissions
  • Process
  • ProcessController
  • ProcessWire
  • Role
  • Roles
  • Sanitizer
  • Selector
  • SelectorBitwiseAnd
  • SelectorContains
  • SelectorContainsLike
  • SelectorContainsWords
  • SelectorEnds
  • SelectorEqual
  • SelectorGreaterThan
  • SelectorGreaterThanEqual
  • SelectorLessThan
  • SelectorLessThanEqual
  • SelectorNotEqual
  • Selectors
  • SelectorStarts
  • Session
  • SessionCSRF
  • SmartyPants_Parser
  • SmartyPantsTypographer_Parser
  • SystemUpdate1
  • Template
  • TemplateFile
  • Templates
  • TemplatesArray
  • Textformatter
  • Textile
  • User
  • Users
  • Wire
  • WireArray
  • WireData
  • WireInput
  • WireInputData
  • WireSaveableItems
  • WireSaveableItemsLookup
  • WireUpload

Interfaces

  • CommentFormInterface
  • CommentListInterface
  • ConfigurableModule
  • FieldtypeLanguageInterface
  • FieldtypePageTitleCompatible
  • HasLookupItems
  • HasRoles
  • InputfieldHasArrayValue
  • Module
  • Saveable
  • TrackChanges

Exceptions

  • ProcessController404Exception
  • ProcessControllerPermissionException
  • Wire404Exception
  • WireDatabaseException
  • WireException
  • WirePermissionException

Functions

  • __
  • _n
  • _x
  • fuel
  • identify_modifier_markdown
  • Markdown
  • mdwp_add_p
  • mdwp_hide_tags
  • mdwp_show_tags
  • mdwp_strip_p
  • ProcessWireClassLoader
  • ProcessWireHostSiteConfig
  • ProcessWireShutdown
  • removeNewlines
  • SmartDashes
  • SmartEllipsis
  • SmartQuotes
  • smarty_modifier_markdown
  • smarty_modifier_smartypants
  • SmartyPants
  • tabIndent
  • unregisterGLOBALS
  • wire
  • wireDecodeJSON
  • wireEncodeJSON
  • wireMkdir
  • Overview
  • Namespace
  • Class
  • Tree
  • Download

Class Pages

ProcessWire Pages

Manages Page instances, providing find, load, save and delete capabilities, some of which are delegated to other classes but this provides the interface to them.

This is the most used object in the ProcessWire API.

Wire implements TrackChanges
Extended by Pages
TODO: Move everything into delegate classes, leaving this as just the interface to them. ProcessWire 2.x Copyright (C) 2011 by Ryan Cramer Licensed under GNU/GPL v2, see LICENSE.TXT http://www.processwire.com http://www.ryancramer.com
Located at core/Pages.php
Methods summary
public
# __construct( )

Create the Pages object

Create the Pages object

public PageArray
# ___find( string $selectorString, array $options = array() )

Given a Selector string, return the Page objects that match in a PageArray.

Given a Selector string, return the Page objects that match in a PageArray.

Parameters

$selectorString
string
$options
array
- findOne: apply optimizations for finding a single page and include pages with 'hidden' status

Returns

PageArray
public Page|null
# findOne( string $selectorString, $options = array() )

Like find() but returns only the first match as a Page object (not PageArray)

Like find() but returns only the first match as a Page object (not PageArray)

Parameters

$selectorString
string
$options

Returns

Page|null
public Page|NullPage
# get( string $selectorString )

Returns only the first match as a Page object (not PageArray).

Returns only the first match as a Page object (not PageArray).

This is an alias of the findOne() method for syntactic convenience and consistency. Using get() is preferred.

Parameters

$selectorString
string

Returns

Page|NullPage
Always returns a Page object, but will return NullPage (with id=0) when no match found
public PageArray
# getById( array|WireArray|string $ids, Template $template = null, integer $parent_id = null )

Given an array or CSV string of Page IDs, return a PageArray

Given an array or CSV string of Page IDs, return a PageArray

Parameters

$ids
array|WireArray|string
Array of IDs or CSV string of IDs
$template
Template
Specify a template to make the load faster, because it won't have to attempt to join all possible fields... just those used by the template.
$parent_id
integer
Specify a parent to make the load faster, as it reduces the possibility for full table scans

Returns

PageArray
public integer
# count( string $selectorString, $options = array() )

Count and return how many pages will match the given selector string

Count and return how many pages will match the given selector string

Parameters

$selectorString
string
$options

Returns

integer
public boolean
# isSaveable( Page $page, string & $reason )

Is the given page in a state where it can be saved?

Is the given page in a state where it can be saved?

Parameters

$page
Page
$reason
string
Text containing the reason why it can't be saved (assuming it's not saveable)

Returns

boolean
True if saveable, False if not
protected
# ___setupNew( Page $page )

Validate that a new page is in a saveable condition and correct it if not.

Validate that a new page is in a saveable condition and correct it if not.

Currently just sets up up a unique page->name based on the title if one isn't provided already.

public boolean
# ___save( Page $page, $options = array() )

Save a page object and it's fields to database.

Save a page object and it's fields to database.

If the page is new, it will be inserted. If existing, it will be updated.

This is the same as calling $page->save()

If you want to just save a particular field in a Page, use $page->save($fieldName) instead.

Parameters

$page
Page
$options

Returns

boolean
True on success
public boolean
# ___saveField( Page $page, string|Field $field )

Save just a field from the given page as used by Page::save($field)

Save just a field from the given page as used by Page::save($field)

This function is public, but the preferred manner to call it is with $page->save($field)

Parameters

$page
Page
$field
string|Field
$fieldName

Returns

boolean
True on success
protected
# saveParents( integer $pages_id, integer $numChildren )

Save references to the Page's parents in pages_parents table, as well as any other pages affected by a parent change

Save references to the Page's parents in pages_parents table, as well as any other pages affected by a parent change

Any pages_id passed into here are assumed to have children

Parameters

$pages_id
integer
ID of page to save parents from
$numChildren
integer
Number of children this Page has
protected
# savePageStatus( integer $pageID, integer $status, boolean $recursive = false, boolean $remove = false )

Sets a new Page status and saves the page, optionally recursive with the children, grandchildren, and so on.

Sets a new Page status and saves the page, optionally recursive with the children, grandchildren, and so on.

While this can be performed with other methods, this is here just to make it fast for internal/non-api use. See the trash and restore methods for an example.

Parameters

$pageID
integer
$status
integer
Status per flags in Page::status* constants
$recursive
boolean
Should the status descend into the page's children, and grandchildren, etc?
$remove
boolean
Should the status be removed rather than added?
public boolean
# isDeleteable( Page $page )

Is the given page deleteable?

Is the given page deleteable?

Note: this does not account for user permission checking. It only checks if the page is in a state to be saveable via the API.

Parameters

$page
Page

Returns

boolean
True if deleteable, False if not
public boolean
# ___trash( Page $page, boolean $save = true )

Move a page to the trash

Move a page to the trash

If you have already set the parent to somewhere in the trash, then this method won't attempt to set it again.

Parameters

$page
Page
$save
boolean
Set to false if you will perform the save() call, as is the case when called from the Pages::save() method.

Returns

boolean
protected boolean
# ___restore( Page $page, boolean $save = true )

Restore a page from the trash back to a non-trash state

Restore a page from the trash back to a non-trash state

Note that this method assumes already have set a new parent, but have not yet saved

Parameters

$page
Page
$save
boolean
Set to false if you only want to prep the page for restore (i.e. being saved elsewhere)

Returns

boolean
public boolean
# ___delete( Page $page, boolean $recursive = false )

Permanently delete a page and it's fields.

Permanently delete a page and it's fields.

Unlike trash(), pages deleted here are not restorable.

If you attempt to delete a page with children, and don't specifically set the $recursive param to True, then this method will throw an exception. If a recursive delete fails for any reason, an exception will be thrown.

Parameters

$page
Page
$recursive
boolean
If set to true, then this will attempt to delete all children too.

Returns

boolean
public Page
# ___clone( Page $page, Page $parent = null, boolean $recursive = true )

Clone an entire page, it's assets and children and return it.

Clone an entire page, it's assets and children and return it.

Parameters

$page
Page
Page that you want to clone
$parent
Page
New parent, if different (default=same parent)
$recursive
boolean
Clone the children too? (default=true)

Returns

Page
the newly cloned page or a NullPage() with id=0 if unsuccessful.
public Page|array|null
# getCache( integer|string|null $id = null )

Given a Page ID, return it if it's cached, or NULL of it's not.

Given a Page ID, return it if it's cached, or NULL of it's not.

If no ID is provided, then this will return an array copy of the full cache.

You may also pass in the string "id=123", where 123 is the page_id

Parameters

$id
integer|string|null

Returns

Page|array|null
public
# cache( Page $page )

Cache the given page.

Cache the given page.

Parameters

$page
Page
public
# uncache( Page $page )

Remove the given page from the cache.

Remove the given page from the cache.

Note: does not remove pages from selectorCache. Call uncacheAll to do that.

Parameters

$page
Page
public
# uncacheAll( )

Remove all pages from the cache.

Remove all pages from the cache.

protected
# selectorCache( string $selector, array $options, PageArray $pages )

Cache the given selector string and options with the given PageArray

Cache the given selector string and options with the given PageArray

Parameters

$selector
string
$options
array
$pages
PageArray
return bool True of pages were cached, false if not
protected array|null|string
# getSelectorCache( string $selector, array $options, boolean $returnSelector = false )

Retrieve any cached page IDs for the given selector and options OR false if none found.

Retrieve any cached page IDs for the given selector and options OR false if none found.

You may specify a third param as TRUE, which will cause this to just return the selector string (with hashed options)

Parameters

$selector
string
$options
array
$returnSelector
boolean
default false

Returns

array|null|string
public PagesSortFields
# sortfields( )

For internal Page instance access, return the Pages sortfields property

For internal Page instance access, return the Pages sortfields property

Returns

PagesSortFields
public mixed|null
# __get( string $key )

Return a fuel or other property set to the Pages instance

Return a fuel or other property set to the Pages instance

Parameters

$key
string
$name

Returns

mixed|null
public
# setOutputFormatting( $outputFormatting = true )

Set whether loaded pages have their outputFormatting turn on or off

Set whether loaded pages have their outputFormatting turn on or off

By default, it is turned on.

protected
# debugLog( string $action = '', string $details = '', string|object $result = '' )

Log a Pages class event

Log a Pages class event

Only active in debug mode.

Parameters

$action
string
Name of action/function that occurred.
$details
string
Additional details, like a selector string.
$result
string|object
The value that was returned.
public array
# getDebugLog( string $action = '' )

Get the Pages class debug log

Get the Pages class debug log

Only active in debug mode

Parameters

$action
string
Optional action within the debug log to find

Returns

array
protected
# ___added( Page $page )

Hook called when a new page has been added

Hook called when a new page has been added

protected
# ___moved( Page $page )

Hook called when a page has been moved from one parent to another

Hook called when a page has been moved from one parent to another

Note the previous parent is in $page->parentPrevious

protected
# ___templateChanged( Page $page )

Hook called when a page's template has been changed

Hook called when a page's template has been changed

Note the previous template is in $page->templatePrevious

protected
# ___trashed( Page $page )

Hook called when a page has been moved to the trash

Hook called when a page has been moved to the trash

protected
# ___restored( Page $page )

Hook called when a page has been moved OUT of the trash

Hook called when a page has been moved OUT of the trash

protected
# ___deleteReady( Page $page )

Hook called when a page is about to be deleted, but before data has been touched

Hook called when a page is about to be deleted, but before data has been touched

This is different from a before(delete) hook because this hook is called once it has been confirmed that the page is deleteable and WILL be deleted.

protected
# ___deleted( Page $page )

Hook called when a page and it's data have been deleted

Hook called when a page and it's data have been deleted

protected
# ___cloned( Page $page, Page $copy )

Hook called when a page has been cloned

Hook called when a page has been cloned

Parameters

$page
Page
The original page to be cloned
$copy
Page
The completed cloned version of the page
Methods inherited from Wire
_(), ___changed(), __call(), __toString(), _n(), _x(), addHook(), addHookAfter(), addHookBefore(), addHookProperty(), className(), error(), fuel(), getAllFuel(), getChanges(), getFuel(), getHooks(), isChanged(), isHooked(), message(), removeHook(), resetTrackChanges(), runHooks(), setFuel(), setTrackChanges(), trackChange(), trackChanges(), untrackChange(), useFuel()
Properties summary
protected $pageFinder
#

Instance of PageFinder for finding pages

Instance of PageFinder for finding pages

protected $templates
#

Instance of Templates

Instance of Templates

protected $sortfields
#

Instance of PagesSortfields

Instance of PagesSortfields

protected array $pageIdCache array()
#

Pages that have been cached, indexed by ID

Pages that have been cached, indexed by ID

protected array $pageSelectorCache array()
#

Cached selector strings and the PageArray that was found.

Cached selector strings and the PageArray that was found.

protected boolean $outputFormatting false
#

Controls the outputFormatting state for pages that are loaded

Controls the outputFormatting state for pages that are loaded

protected array $debugLog array()
#

Runtime debug log of Pages class activities, see getDebugLog()

Runtime debug log of Pages class activities, see getDebugLog()

protected $config null
#

Shortcut to $config API var

Shortcut to $config API var

Properties inherited from Wire
$changes, $defaultHookOptions, $fuel, $hookMethodCache, $localHooks, $staticHooks, $trackChanges, $useFuel
ProcessWire API documentation generated by ApiGen 2.6.0