$templates

Manages and provides access to all the Templates.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Templates class also inherits all the methods and properties of: WireSaveableItems and Wire.

Show $var?     Show args?       Only hookable?    

Common

NameReturnSummary 
$templates->add(string $name)
Template

Add and save new template (and fieldgroup) with given name and return it

 
$templates->clone($item)
bool Template

Clone the given Template

$templates->delete($item)
bool

Delete a Template

$templates->get($key)
Template null string

Get a template by name or ID

 
$templates->getNumPages(Template $tpl)
int

Return the number of pages using the provided Template

 
$templates->getPageClass(Template $template)
string

Get class name to use for pages using given Template

 
$templates->getParentPage(Template $template)
Page NullPage null PageArray

Return the parent page that this template assumes new pages are added to

 
$templates->getParentPages(Template $template)
PageArray

Return all possible parent pages for the given template, if predefined

 
$templates->getTags()
array

Get all tags used by templates

$templates->rename(Template $template, string $name)
None

Rename given template (and its fieldgroup, and file, when possible)

 
$templates->save($item)
bool

Save a Template

For hooks

These methods are only useful for hooking and should not be called directly.

NameReturnSummary 
$templates->fileModified(Template $template)
None

Hook called when a Template detects that its file has changed

Additional methods and properties

In addition to the methods and properties above, Templates also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.252