Template

The template object provides access to properties/settings defined within the Template Config file at runtime.

Instantiation

Template objects are automatically supplied at runtime, but can be instantiated manually if necessary.

<?ev
    var default_template = new Template('page/index');
?>

Construct parameters
reference

Type String

The reference must be a valid template reference, which is made up of controller/identifier.

  • controller - this is the controller and folder of the template file e.g. page, product or category
  • / - slash separates the controller and identifier
  • identifier - the identifier for the file e.g. index, blog, blog_post etc.


Properties
assets

Type Array

Containing String asset identifiers available to pages with this template. Assets and asset identifiers are defined within the Template Config file i.e. you have full control over what assets are and what they can be used for.

children

Type Array | Boolean

By default this property has a Boolean value of true, meaning that pages with this template may contain any sub-page with the same controller. If set to false pages with this template may not have sub-pages. This property can contain an Array of template identifiers with the same controller. Note that children identifiers must have the same controller, so a "page" controller may not have a child document that is a "category". The value for this property is set within your Template Config file.

This property is available for the following controllers:

  • page
  • category

Note: category controller only currently supports a true value.

id

Type String

The identifier string for the current template.

path

Type String

The raw path as set within the config/templates.json file.
For example the homepage path may resemble ~/theme/page/home.evml

perpage

Type Number

Default value is zero - view all child pages. When greater than zero pages with this template will support pagination and filtering by tag, date, or author of child pages. 

This property is available for the following controllers:

  • page
  • category
settings

Type Object

Contains properties defined with a "template" scope within the Template Config file.

The best way to visualise this is with an excerpt from config/templates.json settings file for a page with properties.


{ 
    ...
    "properties": [
        {
            "title": "Property 1",
            "id": "PROPERTY1",
            "scope": "template",
            "type": "text",
            "value": "VALUE 1 (DEFAULT)"
        }
    ]
    ...
}

...and then the resulting setting object:


The setting is {{ template.settings.PROPERTY1 }}

This property is currently available to the following controllers:

  • page
sort

Type String

Contains the sort order for the current Page template. The sort string is comprised of column:direction. Available settings can be found on the Template Config page.

This property is currently available to the following controllers:

  • page

Note that category sort order is managed within Evance itself per category and you do not need to set it in your Template Config.

tags

Type Array

Contains an Array of String identifiers representing each TagType supported by the template.

This property is currently available to the following controllers:

  • page
title

Type String

The name of the template.