Template

A Template connects a set of fields (via a Fieldgroup) to pages, determines how those pages are rendered (via a template file in /site/templates/), and controls URL behavior, access control, caching, and editor behavior

Template objects are retrieved from the $templates API variable:

$template = $templates->get('basic-page');

See also Templates / $templates API.md file, or Templates documentation for creating, saving, deleting, and cloning templates.

Identification
PropertyTypeDescription
idintNumeric database ID
namestringTemplate name (also used as the template filename base)
labelstringOptional admin label
flagsintBitmask of Template::flag* constants
modifiedintUnix timestamp of last modification to template or file
nsstringPHP namespace detected in the template file
pageClassstringCustom Page class for pages using this template; blank means Page
pageLabelFieldstringField name(s) or markup displayed in the page list; may also embed an icon

$template->getLabel($language)

Return the template label for the current (or specified) language. Falls back to $template->name when no label is set.

  • Arguments: getLabel(Language|string|int|null $language = null)
  • Returns: string
echo $template->getLabel(); // current language label or template name
echo $template->getLabel('spanish'); 

$template->setLabel($label, $language)

Set the template label for the default (or specified) language.

  • Arguments: setLabel(string $label, Language|string|int|null $language = null)
  • Returns: self
  • Note: If no language is specified, the language named default is used.
$template->setLabel('Basic Page'); // default language (not necessarily current)
$template->setLabel('Página básica', 'spanish'); 

$template->getIcon($prefix)

Return the icon name used by this template, as stored in pageLabelField.

  • Arguments: getIcon(bool $prefix = false)
  • Returns: string — FontAwesome icon name without fa- prefix by default
$icon = $template->getIcon(); // e.g. "star"
$icon = $template->getIcon(true); // e.g. "fa-star"

$template->setIcon($icon)

Set the icon for this template. The icon is stored as part of pageLabelField.

  • Arguments: setIcon(string $icon)
  • Returns: $this
$template->setIcon('star'); // font-awesome icon name
$template->save();

$template->getNumPages()

Return the number of pages using this template.

  • Returns: int
echo $template->getNumPages();

$template->getPageClass($withNamespace)

Get the PHP class name used for pages with this template. May differ from $template->pageClass when a custom class is auto-detected at runtime (e.g. BlogPostPage for template blog-post).

  • Arguments: getPageClass(bool $withNamespace = true)
  • Returns: string
  • Available 3.0.152.
$class = $template->getPageClass(); // e.g. "ProcessWire\BlogPostPage"
$class = $template->getPageClass(false); // e.g. "BlogPostPage"

To create a page class that the template will use:

  1. Ensure that $config->usePageClasses = true; in /site/config.php.
  2. Create a PHP class file in /site/classes/ using the template name in Pascal Case followed by the word Page, e.g. template blog-post would use BlogPostPage.php
  3. Create the class in the file you created above:
    <?php namespace ProcessWire;  
    class BlogPostPage extends Page {}
  4. Pages using the template blog-post will now use class BlogPostPage rather than Page.

$template->editUrl($http)

Return the admin URL to edit this template's settings.

  • Arguments: editUrl(bool $http = false)
  • Returns: string
echo $template->editUrl(); // /processwire/setup/template/edit?id=12
Fieldgroup and fields

A Template always has exactly one Fieldgroup. Accessing $template->fieldgroup (or the alias $template->fields) gives you the Fieldgroup, which you can iterate to access the template's fields.

// Iterate fields in this template
foreach($template->fieldgroup as $field) {
    echo $field->name . "\n";
}

// Check if template has a specific field
if($template->hasField('body')) {
    $field = $template->fieldgroup->getField('body');
}

$template->hasField($name)

Return true if this template's fieldgroup contains the given field.

  • Arguments: hasField(Field|string|int $name)
  • Returns: bool

$template->setFieldgroup($fieldgroup)

Assign a different Fieldgroup to this template. Save the template afterward to persist. Throws a WireException if the template is a system template or has permanent fields.

  • Arguments: setFieldgroup(Fieldgroup $fieldgroup)
  • Returns: $this
$template->setFieldgroup($fieldgroups->get('other-fieldgroup'));
$template->save();

This is rarely used in practice as most templates have a matching (by name) fieldgroup.

Access control

Access control is enabled per-template by setting $template->useRoles = 1 and then assigning roles. When useRoles is 0 (the default), the template inherits access from the closest parent page with a template that defines access control.

PropertyTypeDescription
useRolesint\|boolEnable role-based access control for this template (0=no, 1=yes)
rolesPageArrayRoles with page-view access (PageArray of Role objects)
editRolesarrayRole IDs that may edit pages
addRolesarrayRole IDs that may add children to pages
createRolesarrayRole IDs that may create new pages
rolesPermissionsarrayPer-role permission overrides: [roleId => [permId, -permId, ...]] where positive ID adds, negative ID removes
noInheritintPrevent edit/add/create access from inheriting to non-access-controlled children (0=inherit, 1=no inherit)
redirectLoginintBehavior on access denied: 0=404, 1=login page, or page ID/URL to redirect to
guestSearchableintPages appear in search results even when guest has no view access (0=no, 1=yes)

$template->getRoles($type)

Return a PageArray of roles assigned to this template for the given access type.

  • Arguments: getRoles(string $type = 'view')
  • Returns: PageArray
  • $type may be 'view' (default), 'edit', 'create', or 'add'.
$viewRoles = $template->getRoles(); // view roles
$editRoles = $template->getRoles('edit');

$template->hasRole($role, $type)

Return true if this template has the given role for the specified access type.

  • Arguments: hasRole(Role|string|int $role, string $type = 'view')
  • Returns: bool
if($template->hasRole('guest')) {
    // guest can view pages using this template
}
if($template->hasRole('editor', 'edit')) {
    // editors can edit
}

$template->addRole($role, $type)

Add a role to this template for the given access type. Save the template afterward.

  • Arguments: addRole(Role|int|string $role, string $type = 'view')
  • Returns: $this
$template->addRole('guest'); // add view access for guest
$template->addRole('editor', 'edit'); // add edit access for editor
$template->save();

$template->removeRole($role, $type)

Remove a role from this template for the given access type. Specify 'all' for $type to remove the role from every access type at once.

  • Arguments: removeRole(Role|int|string $role, string $type = 'view')
  • Returns: $this
$template->removeRole('editor', 'edit');
$template->removeRole('old-role', 'all'); // remove from all access types
$template->save();

$template->addPermissionByRole($permission, $role, $test)

Add a permission override that applies to users with a specific role on pages using this template. Does not affect access to the page-view or page-edit permissions managed through addRole()/removeRole() — this is for custom permission overrides.

  • Arguments: addPermissionByRole(Permission|int|string $permission, Role|int|string $role, bool $test = false)
  • Returns: booltrue if an update was (or would be) made, false if not.
  • Specify true for $test to only test if an update would be made (see return value), without changing anything.
$template->addPermissionByRole('page-publish', 'editor');
$template->save();

$template->revokePermissionByRole($permission, $role, $test)

Revoke a permission for users with a specific role.

  • Arguments: revokePermissionByRole(Permission|int|string $permission, Role|int|string $role, bool $test = false)
  • Returns: bool
  • Specify true for $test to only test if an update would be made (see return value), without changing anything.
Family settings

Family settings control the parent/child relationships between pages.

PropertyTypeDescription
noChildrenintPrevent child pages (0=children allowed, 1=no children)
noParentsint0=any parent, 1=no new pages, -1=only one page of this template may exist
childTemplatesint[]IDs of templates allowed for children; empty array = any
parentTemplatesint[]IDs of templates allowed for parents; empty array = any
sortfieldstringField name to sort children by; blank = page decides; sort = manual
childNameFormatstringAuto-name format for new child pages (date format or title or counter)

$template->childTemplates($setValue)

Get or set the templates allowed for children of pages using this template.

  • Arguments: childTemplates(array|TemplatesArray|null $setValue = null)
  • Returns: TemplatesArray
  • Applies only if the noChildren setting is 0 (children allowed).
  • Available 3.0.153.
// Get child templates
$allowed = $template->childTemplates();
foreach($allowed as $t) echo $t->name . "\n";

// Set child templates (by name, ID, or Template object)
$template->childTemplates(['blog-post', 'event']);
$template->save();

// Allow any template for children (clear restrictions)
$template->childTemplates([]);
$template->save();

$template->parentTemplates($setValue)

Get or set the templates allowed for parents of pages using this template.

  • Arguments: parentTemplates(array|TemplatesArray|null $setValue = null)
  • Returns: TemplatesArray
  • Applies only if the noParents setting is 0 or -1.
  • Available 3.0.153.
$template->parentTemplates(['blog']); // only pages with 'blog' template may be parents
$template->save();

$template->allowNewPages()

Return true if new pages using this template may be created, based on noParents.

  • Returns: bool
if($template->allowNewPages()) {
    // safe to create a new page with this template
}

$template->getParentPage($checkAccess)

Return the defined parent page for new pages using this template (based on family settings). Returns null if no parent is defined, NullPage if multiple parents match.

  • Arguments: getParentPage(bool $checkAccess = false)
  • Returns: Page|NullPage|null
$parent = $template->getParentPage();
if($parent && $parent->id) {
    echo "New pages go under: $parent->path";
}

$template->getParentPages($checkAccess)

Return all defined parent pages for this template.

  • Arguments: getParentPages(bool $checkAccess = false)
  • Returns: PageArray
URL settings
PropertyTypeDescription
allowPageNumintAllow page number URL segments (0=no, 1=yes)
urlSegmentsint\|arrayAllow URL segments: 0=no, 1=any, or array of allowed segment strings
httpsintHTTPS enforcement: 0=either, 1=HTTPS only, -1=HTTP only
slashUrlsintTrailing slash on page URLs (1=yes, 0=no)
slashPageNumint\|stringTrailing slash on page number segments (0=either, 1=yes, -1=no)
slashUrlSegmentsint\|stringTrailing slash on last URL segment (0=either, 1=yes, -1=no)

$template->urlSegments($value)

Get or set the URL segments setting.

  • Arguments: urlSegments(array|int|bool|string $value = '~')
  • Returns: array|int — array of specific allowed segments, or 0 if disabled, or 1 if any allowed
  • Omit the argument to get the current value.
  • Pass an array of specific allowed segments, true/1 to allow all, or 0/false to disable.
  • Segment strings may be literal or include 'regex:your-pattern' entries.
// Allow any URL segments
$template->urlSegments(1);

// Only allow specific segments
$template->urlSegments(['archive', 'feed', 'regex:[0-9]{4}']);

// Disable URL segments
$template->urlSegments(0);

$template->save();

$template->isValidUrlSegmentStr($urlSegmentStr)

Check whether a URL segment string is valid for this template's settings.

  • Arguments: isValidUrlSegmentStr(string $urlSegmentStr)
  • Returns: bool
  • Available 3.0.186.
if($template->isValidUrlSegmentStr('foo/bar/baz')) {
    // URL segment string is permitted
}
File settings
PropertyTypeDescription
filenamestringFull path to the template file (auto-generated from name)
altFilenamestringAlternate filename if not based on template name
contentTypestringContent-type header or key from $config->contentTypes
noPrependTemplateFileintDisable auto-prepend of $config->prependTemplateFile (0=use, 1=skip)
noAppendTemplateFileintDisable auto-append of $config->appendTemplateFile (0=use, 1=skip)
prependFilestringFile to prepend (relative to /site/templates/)
appendFilestringFile to append (relative to /site/templates/)
pagefileSecureintSecure file serving: 0=off, 1=yes for non-public pages, 2=always

$template->filename($filename)

Get or set the template filename. When getting, it auto-generates the path from the template name if not already set, and also detects file modifications and namespace.

  • Arguments: filename(string|null $filename = null)
  • Returns: string — full path to the template file
  • You may pass a basename (e.g. 'home.php') or a full path. Available for setting 3.0.143.
$file = $template->filename(); // full path, e.g. /site/templates/basic-page.php
$template->filename('custom-file.php'); // use /site/templates/custom-file.php

$template->filenameExists()

Return true if the template file exists on disk.

  • Returns: bool
if($template->filenameExists()) {
    // template has a PHP file
}
Cache settings

Template caching stores rendered page output for a specified time. A cacheTime of 0 disables caching. Negative values are reserved for external caching engines (e.g. ProCache).

PropertyTypeDescription
cacheTimeintSeconds to cache page output; 0=disabled; negative=external cache
useCacheForUsersint0=guest users only, 1=all users
noCacheGetVarsstringSpace-separated GET vars that bypass the cache
noCachePostVarsstringSpace-separated POST vars that bypass the cache
cacheExpireintHow to expire the cache when a page is saved — see Template::cacheExpire* constants
cacheExpirePagesarrayPage IDs to expire when cacheExpire === Template::cacheExpireSpecific
cacheExpireSelectorstringSelector matching pages to expire when cacheExpire === Template::cacheExpireSelector

Cache expiration constants

ConstantValueDescription
Template::cacheExpirePage0Expire only the saved page
Template::cacheExpireSite1Expire the entire site cache
Template::cacheExpireParents2Expire the saved page and its parents
Template::cacheExpireSpecific3Expire specific pages listed in cacheExpirePages
Template::cacheExpireSelector4Expire pages matching cacheExpireSelector
Template::cacheExpireNone-1Do not expire anything on save
$template->cacheTime = 3600; // cache for 1 hour
$template->useCacheForUsers = 1; // cache for all users
$template->cacheExpire = Template::cacheExpireSite; // expire full cache on save
$template->save();

For a more complete page caching solution see ProCache.

Behaviors

Boolean-style settings that govern page behavior. All are 0 (off) by default unless noted.

PropertyDescription
noGlobalIgnore the global flag on fields (0=respect global, 1=ignore)
noMovePrevent pages from being moved to a different parent
noTrashPrevent pages from being trashed (they are deleted instead)
noChangeTemplatePrevent pages from changing their template
noUnpublishPrevent pages from existing in an unpublished state
noShortcutHide this template from the "Add new page" shortcut menu
noLangDisable multi-language support for pages using this template
allowChangeUserAllow the createdUser field to be changed via API or admin (superuser only)
compilePHP compilation: 0=off, 1=file only, 2=file+includes, 3=auto (default=3)
$template->noTrash = 1; // pages using this template cannot be trashed
$template->noMove = 1; // pages cannot be moved
$template->noLang = 1; // single-language only, even if LanguageSupport active
$template->save();

Note: the compile option applies only if $config->templateCompile is true.

Page editor settings

Settings that affect the admin page editor for pages using this template.

PropertyTypeDescription
nameContentTabintShow the page name field on the Content tab (0=no, 1=yes)
tabContentstringOverride label for the Content tab
tabChildrenstringOverride label for the Children tab
nameLabelstringOverride label for the "Name" field
errorActionintAction when a required field is empty on a published page save: 0=notify, 1=restore previous, 2=unpublish

$template->getTabLabel($tab, $language)

Return the overridden label for a page editor tab, or blank if not overridden.

  • Arguments: getTabLabel(string $tab, Language|string|int|null $language = null)
  • Returns: string
  • $tab should be 'content' or 'children'.
$label = $template->getTabLabel('content'); // blank if not overridden

$template->setTabLabel($tab, $label, $language)

Set label for a page editor tab, optionally for a specific language.

  • Arguments: setTabLabel(string $tab, string $label, Language|string|int|null $language = null)
  • Returns: self
  • $tab should be 'content' or 'children'.
$template->setTabLabel('content', 'Main');

$template->getNameLabel($language)

Return the overridden page name input label, or blank if not overridden.

  • Arguments: getNameLabel(Language|string|int|null $language = null)
  • Returns: string

$template->setNameLabel($label, $language)

Set the page name input label, optionally for a specific language.

  • Arguments: setNameLabel(string $label, Language|string|int|null $language = null)
  • Returns: self
Tags

Tags are space-separated strings stored in $template->tags. They are used to group templates in the admin template list.

$template->getTags()

Return the template's tags as an associative array keyed and valued by tag name.

  • Returns: array[tagName => tagName, ...]
$tags = $template->getTags(); // ['marketing' => 'marketing', 'blog' => 'blog']

$template->hasTag($tag)

Return true if this template has the given tag.

  • Arguments: hasTag(string $tag)
  • Returns: bool

$template->addTag($tag) / $template->removeTag($tag)

Add or remove a tag. Remember to save the template afterward.

  • Returns: $this
$template->addTag('marketing');
$template->removeTag('old-tag');
$template->save();
Languages

$template->getLanguages()

Return a PageArray of languages allowed for pages using this template. Returns null if LanguageSupport is not installed. When $template->noLang is set, returns only the default language.

  • Returns: PageArray|Languages|null
$languages = $template->getLanguages();
if($languages) {
    foreach($languages as $lang) echo $lang->name . "\n";
}
Saving

$template->save()

Save this template to the database. Equivalent to $templates->save($template).

  • Returns: Template|false — returns the Template on success, false on failure
$template->label = 'New Label';
$template->save();
Flag constants
ConstantValueDescription
Template::flagSystem8Template is a system template; name/ID cannot be changed and it cannot be deleted
Template::flagSystemOverride32768Temporary override for system flag — set first, then remove flagSystem in two steps

To remove the system flag from a template:

$template->flags = $template->flags | Template::flagSystemOverride;
$template->flags = $template->flags & ~Template::flagSystem;
$template->flags = $template->flags & ~Template::flagSystemOverride;
$template->save();
Notes
  • Source file: wire/core/Template/Template.php.
  • $template->name is used as the template filename base: basic-page/site/templates/basic-page.php.
  • $template->fieldgroup and $template->fields are aliases for the same Fieldgroup object.
  • $template->cacheTime is a camelCase alias for the underlying cache_time setting.
  • The noChildren, noParents properties may be null, a blank string or 0 when empty — check with (int) cast if comparing numerically.
  • $template->__toString() returns $template->name, so templates in string context produce their name.
API reference: methods, properties

Template objects also maintain several properties which can affect the render behavior of pages using it.


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

Show class?     Show args?       Only hookable?    

Identification

NameReturnSummary 
Template::flags int Flags (bitmask) assigned to this template. See the flag constants.  
Template::getIcon()
string

Return the icon name used by this template

 
Template::getLabel()
string

Return template label for current language, or specified language if provided

 
Template::getLanguages()
PageArray Languages null

Get languages allowed for this template or null if language support not active.

 
Template::getNumPages()
int

Return the number of pages used by this template.

 
Template::getPageClass()
string

Get class name to use for Page objects using this template

 
Template::id int Numeric database ID.  
Template::label string Optional short text label to describe Template.  
Template::name string Name of template.  
Template::ns string Namespace found in the template file, or blank if not determined.  
Template::pageClass string Class for instantiated page objects. Page assumed if blank, or specify class name.  
Template::setIcon(string $icon)
$this

Set the icon to use with this template

 
Template::setLabel(string $label)
$this

Set template label, optionally for a language

 

Family

NameReturnSummary 
Template::allowNewPages()
bool

Allow new pages that use this template?

 
Template::childNameFormat string Name format for child pages. when specified, the page-add UI step can be skipped when adding children. Counter appended till unique. Date format assumed if any non-pageName chars present. Use 'title' to pull from title field.  
Template::childTemplates()
TemplatesArray Template

Get or set child templates (templates allowed for children of pages using this template)


Can also be used as property: Template::childTemplates
 
Template::getParentPage()
Page NullPage null

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

 
Template::getParentPages()
PageArray

Return all defined parent pages for this template

 
Template::noChildren int Set to 1 to cancel use of childTemplates.  
Template::noParents int Set to 1 to cancel use of parentTemplates, set to -1 to only allow one page using this template to exist.  
Template::parentTemplates()
TemplatesArray

Get or set parent templates (templates allowed for parent pages of pages using this template)


Can also be used as property: Template::parentTemplates
 
Template::sortfield string Field that children of templates using this page should sort by (leave blank to let page decide, or specify "sort" for manual drag-n-drop).  

URLs

NameReturnSummary 
Template::allowPageNum int Allow page numbers in URLs? (0=no, 1=yes)  
Template::https int Use https? (0 = http or https, 1 = https only, -1 = http only)  
Template::isValidUrlSegmentStr(string $urlSegmentStr)
bool

Is the given URL segment string allowed according to this template’s settings?

 
Template::slashPageNum string int Should PageNum segments have a trailing slash? (0=either, 1=yes, -1=no) applies only if allowPageNum!=0.  
Template::slashUrlSegments string int Should last URL segment have a trailing slash? (0=either, 1=yes, -1=no) applies only if urlSegments!=0.  
Template::slashUrls int Page URLs should have a trailing slash? 1 = yes, 0 = no  
Template::urlSegments()
array int

Get or set allowed URL segments


Can also be used as property: Template::urlSegments
 

Access

NameReturnSummary 
Template::addRoles array Array of Role IDs that may add pages using this template.  
Template::createRoles array Array of Role IDs that may create pages using this template.  
Template::editRoles array Array of Role IDs that may edit pages using this template.  
Template::getRoles()
PageArray

Get the role pages that are part of this template

 
Template::guestSearchable int Pages appear in search results even when user doesnt have access? (0=no, 1=yes)  
Template::hasRole($role)
bool

Does this template have the given Role?

 
Template::noInherit int Disable role inheritance? Specify 1 to prevent edit/create/add access from inheriting to children, or 0 for default inherit behavior.  
Template::redirectLogin int Redirect when no access: 0 = 404, 1 = login page, url = URL to redirect to, int(>1) = ID of page to redirect to.  
Template::roles PageArray Roles assigned to this template for view access.  
Template::rolesPermissions array Override permissions: Array indexed by role ID with values as permission ID (add) or negative permission ID (revoke).  
Template::setRoles($value)
None

Set roles for this template

 
Template::useRoles int bool Whether or not this template defines access.  

Files

NameReturnSummary 
Template::altFilename string Alternate filename for template file, if not based on template name.  
Template::appendFile string File to append to template file (separate from $config->appendTemplateFile).  
Template::contentType string Content-type header or index (extension) of content type header from $config->contentTypes  
Template::filename()
string

Return corresponding template filename including path, or set template filename


Can also be used as property: Template::filename
 
Template::filenameExists()
bool

Does the template filename exist?

 
Template::noAppendTemplateFile int bool Disabe automatic append of $config->appendTemplateFile (if in use).  
Template::noPrependTemplateFile int bool Disable automatic prepend of $config->prependTemplateFile (if in use).  
Template::pagefileSecure int Use secure pagefiles for pages using this template? 0=No/not set, 1=Yes (for non-public pages), 2=Always 3.0.166+  
Template::prependFile string File to prepend to template file (separate from $config->prependTemplateFile).  

Cache

NameReturnSummary 
Template::cacheExpire int Expire the cache for all pages when page using this template is saved? (1 = yes, 0 = no- only current page)  
Template::cacheExpirePages array Array of Page IDs that should be expired, when cacheExpire == Template::cacheExpireSpecific  
Template::cacheExpireSelector string Selector string matching pages that should be expired, when cacheExpire == Template::cacheExpireSelector  
Template::cacheTime int Number of seconds pages using this template should cache for, or 0 for no cache. Negative values indicates setting used for external caching engine like ProCache.  
Template::noCacheGetVars string GET vars that trigger disabling the cache (only when cache_time > 0)  
Template::noCachePostVars string POST vars that trigger disabling the cache (only when cache_time > 0)  
Template::useCacheForUsers int Use cache for: 0 = only guest users, 1 = guests and logged in users  

Page editor

NameReturnSummary 
Template::errorAction int Action to take when published page missing required field is saved (0=notify only, 1=restore prev value, 2=unpublish page)  
Template::getNameLabel()
string

Return the overriden "page name" label, or blank if not overridden

 
Template::getTabLabel(string $tab)
string

Return page editor tab label for current language (or specified language if provided)

 
Template::nameContentTab int Pages should display the name field on the content tab? (0=no, 1=yes)  
Template::nameLabel string Optional replacement for the default "Name" label on pages using this template  
Template::setTabLabel(string $tab, string $label)
$this

Set a page editor tab label for default language (or specified language)

 
Template::tabChildren string Optional replacement for default "Children" label  
Template::tabContent string Optional replacement for default "Content" label  

Behaviors

NameReturnSummary 
Template::allowChangeUser int Allow the createdUser/created_users_id field of pages to be changed? (with API or in admin w/superuser only). 0=no, 1=yes  
Template::noChangeTemplate int Don't allow pages using this template to change their template? (0=template change allowed, 1=template change not allowed)  
Template::noGlobal int Template should ignore the global option of fields? (0=no, 1=yes)  
Template::noLang int Disable multi-language for this template (when language support active).  
Template::noMove int Pages using this template are not moveable? (0=moveable, 1=not movable)  
Template::noSettings int Don't show a settings tab on pages using this template? (0=use settings tab, 1=no settings tab)  
Template::noShortcut int Don't allow pages using this template to appear in shortcut "add new page" menu.  
Template::noTrash int Pages using this template may not go in trash? (i.e. they will be deleted not trashed) (0=trashable, 1=not trashable)  
Template::noUnpublish int Don't allow pages using this template to ever exist in an unpublished state - if page exists, it must be published. (0=page may be unpublished, 1=page may not be unpublished)  

Other

NameReturnSummary 
Template::compile int Set to 1 to enable compilation, 2 to compile file and included files, 3 for auto, or 0 to disable.  
Template::pageLabelField string CSV or space separated string of field names to be displayed by ProcessPageList (overrides those set with ProcessPageList config).  

Common

NameReturnSummary 
Template::addPermissionByRole($permission, $role)
bool

Add a permission that applies to users having a specific role with pages using this template

 
Template::addRole($role)
$this

Add a Role to this template for view, edit, create, or add permission

 
Template::editUrl()
string

URL to edit template settings (for administrator)

 
Template::removeRole($role)
$this

Remove a Role to this template for view, edit, create, or add permission

 
Template::revokePermissionByRole($permission, $role)
bool

Revoke a permission that applies to users having a specific role with pages using this template

 
Template::setNameLabel(string $label)
$this

Set custom label for page name input in page editor

 

Fields

NameReturnSummary 
Template::fieldgroup Fieldgroup Field[] The Fieldgroup used by the template. Can also be used to iterate a Template's fields.  
Template::fieldgroupPrevious Fieldgroup null Previous fieldgroup, if it was changed. Null if not.  
Template::hasField($name)
bool

Does this template have the given Field?

 
Template::setFieldgroup(Fieldgroup $fieldgroup)
$this

Set this Template's Fieldgroup

 

Tags

NameReturnSummary 
Template::addTag(string $tag)
$this

Add tag

 
Template::getTags()
array

Get tags array

 
Template::hasTag(string $tag)
bool

Does this template have given tag?

 
Template::removeTag(string $tag)
self

Remove tag

 
Template::tags string Optional tags that can group this template with others in the admin templates list.  

Properties

NameReturnSummary 
Template::modified int Last modified time for template or template file 

Additional methods and properties

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

API reference based on ProcessWire core version 3.0.264