$templatesnewTemplate()

Create new template in memory

Available since version 3.0.258.

Example

$template = $templates->newTemplate('product'); 
$template->label = 'Product item';
$template->save();

Usage

// basic usage
$template = $templates->newTemplate($name);

// usage with all arguments
$template = $templates->newTemplate($name, $settings = []);

Arguments

NameType(s)Description
$namestring array

Name of template or array of settings that includes 'name', and anything else that would usually go in $settings array.

$settings (optional)array string

Array of settings to set, or string for template label only

Return value

Exceptions

Method can throw exceptions on error:

  • WireException - If given a template name that already exists


$templates methods and properties

API reference based on ProcessWire core version 3.0.259