Page
in package
Methods for working with CMS pages
Table of Contents
Methods
- activateRevision() : void
- Makes a particular revision live, and changes the status of the previous live revision to 'old'.
- attrs() : mixed
- Returns an array of key-value pairs of all attributes for a page
- canonicalUrl() : string
- Get the canonical URL for a page either from the Custom Meta or from the page URL
- current() : array<string|int, mixed>|null
- Return details for current page
- determineRelatedLinks() : array<string|int, mixed>
- Return list of related links for given page
- getContentWidgets() : array<string|int, mixed>
- Gets the embedded widgets (i.e. content blocks) for a page
- getText() : string
- Get the page text for a page id, in HTML format, with widgets and everything, ready to go
- injectPageSkin() : mixed
- Inject page details -- title and browser title -- into a skin view
- lastModified() : string|null
- Return the last-modified date of the specified page.
- loadPageMeta() : mixed
- Load page metadata - description and keywords
- loadPageSocial() : void
- Load page social - title, image, description, url
- lookupUrl() : mixed
- Get the page id for a given URL
- pagesWithAttr() : array<string|int, mixed>
- Returns an array pages which contain a given attribute.
- pagesWithWidget() : array<string|int, mixed>
- Find pages with a given widget, and optionally the specified settings.
- setupToolPage() : array<string|int, mixed>|null
- Set up metadata and social metadata for a tool page
- toolUrl() : string
- Fetches the URL for a tool page for a specific controller entrance method
- url() : string|null
- Return the URL for a page, when given the page id The URLs are relative
- determineNodeLinks() : array<string|int, mixed>
- Traverse page node to extract page links
Methods
activateRevision()
Makes a particular revision live, and changes the status of the previous live revision to 'old'.
public
static activateRevision(mixed $rev_id) : void
Should be run inside a transaction.
Parameters
- $rev_id : mixed
-
ID of revision to make live
attrs()
Returns an array of key-value pairs of all attributes for a page
public
static attrs(mixed $id) : mixed
Parameters
- $id : mixed
canonicalUrl()
Get the canonical URL for a page either from the Custom Meta or from the page URL
public
static canonicalUrl(int $page_id) : string
Parameters
- $page_id : int
-
Page ID
Return values
string —Canonical URL
current()
Return details for current page
public
static current() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —DB row
determineRelatedLinks()
Return list of related links for given page
public
static determineRelatedLinks(int $page_id) : array<string|int, mixed>
Parameters
- $page_id : int
Return values
array<string|int, mixed> —[href, text] pairs
getContentWidgets()
Gets the embedded widgets (i.e. content blocks) for a page
public
static getContentWidgets(int $rev_id, string $include) : array<string|int, mixed>
Parameters
- $rev_id : int
-
Page revision ID from database (page_revisions.id)
- $include : string
-
'active' to only include active widgets, 'all' to include disabled widgets as well
Return values
array<string|int, mixed> —Rows extracted from the database
getText()
Get the page text for a page id, in HTML format, with widgets and everything, ready to go
public
static getText(int $page_id[, int $rev_id = 0 ][, int $subsite_id = null ]) : string
Parameters
- $page_id : int
-
Page ID from database
- $rev_id : int = 0
-
If specified, that revision will be used. Otherwise, the current live revision will be used. N.B. if specified, it must be a valid revision for the specified page
- $subsite_id : int = null
-
Optional subsite ID - this is required for admins editing a sub-site that's different from the domain
Tags
Return values
string —HTML
injectPageSkin()
Inject page details -- title and browser title -- into a skin view
public
static injectPageSkin(BaseView $skin, array<string|int, mixed> $page) : mixed
Parameters
- $skin : BaseView
-
Skin view to inject details into
- $page : array<string|int, mixed>
-
Page to pull details from
lastModified()
Return the last-modified date of the specified page.
public
static lastModified([int $page_id = null ][, string $date_format = 'd/m/Y' ]) : string|null
Returns NULL on error.
If you don't provide a page-id, uses the id of the Navigation::matchedNode()
The date is formatted using the php date function. The default date format is "d/m/Y".
Parameters
- $page_id : int = null
-
The page to get the last-modified date of
- $date_format : string = 'd/m/Y'
-
The date format to return the date in
Return values
string|null —Date or null If page could not be found
loadPageMeta()
Load page metadata - description and keywords
public
static loadPageMeta(array<string|int, mixed> $page) : mixed
Parameters
- $page : array<string|int, mixed>
-
Page record from database
loadPageSocial()
Load page social - title, image, description, url
public
static loadPageSocial(array<string|int, mixed> $page[, Pagenode|null $node = null ]) : void
Parameters
- $page : array<string|int, mixed>
-
Page record from database
- $node : Pagenode|null = null
-
Node, for generating the URL; optional
lookupUrl()
Get the page id for a given URL
public
static lookupUrl(mixed $url) : mixed
Parameters
- $url : mixed
pagesWithAttr()
Returns an array pages which contain a given attribute.
public
static pagesWithAttr(string $attr_name[, string $attr_value = null ]) : array<string|int, mixed>
Parameters
- $attr_name : string
-
Attribute name to search for
- $attr_value : string = null
-
If set, require the attribute to be this value
Tags
Return values
array<string|int, mixed> —Page IDs
pagesWithWidget()
Find pages with a given widget, and optionally the specified settings.
public
static pagesWithWidget(string $widget_name[, array<string|int, mixed> $settings = [] ]) : array<string|int, mixed>
Only widgets on live revisions of active pages are checked.
Parameters
- $widget_name : string
-
The class of the desired widget.
- $settings : array<string|int, mixed> = []
-
The settings to look for; all of the specified settings must match.
Tags
Return values
array<string|int, mixed> —Page IDs
setupToolPage()
Set up metadata and social metadata for a tool page
public
static setupToolPage() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —$page Page record from database or null Current URL is not a matched node
toolUrl()
Fetches the URL for a tool page for a specific controller entrance method
public
static toolUrl(string|Controller $class, string $method) : string
Parameters
- $class : string|Controller
-
Class
- $method : string
-
Method
Tags
Return values
string —The URL to access the tool page
url()
Return the URL for a page, when given the page id The URLs are relative
public
static url(int $id) : string|null
Parameters
- $id : int
-
The page id to return the URL for
Return values
string|null —The friendly URL for the page or null if not found
determineNodeLinks()
Traverse page node to extract page links
private
static determineNodeLinks(Pagenode $node, int $depth) : array<string|int, mixed>
Parameters
- $node : Pagenode
-
The node to traverse
- $depth : int
Return values
array<string|int, mixed> —[href, text] pairs