Template

Template

{{ template }}

Name Type Description
object_type String Will always be datastore_item
is_valid Boolean True if this references a published template
guid String The unique identifier for this template
value String Contains the same value as guid
name text The name of the template which, when combined together with the path, uniquely identifies the template on this site
path String The path, exluding filename, of this template used for organizational and reference purposes
type select Field type (e.g., text, textarea, select, checkbox, etc.)
markup code Template markup/source code
field_id String The identifier for this field
label String The label for this field
output String Outputs the rendered template in a new child scope - similar to calling {% include %} with the current template.

{{ templates }}

Contains multiple templates.

Name Type Description
output String The default output that the templates will produce when it is output directly to the template - using the "output_in_list" property of each template in the items list

{% template %}

{% template
var|set|assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this template is stored on. "var" is the default behavior.
variable_name
 
Specify a variable name in order to save this template to a variable. If not specified, it will be output to the template instead.
output_to_template
 
If included the template will be output directly to the template.
=
%}

{% templates %}

{% templates
var|set|assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this templates is stored on. "var" is the default behavior.
variable_name
 
Specify a variable name in order to save this templates to a variable. If not specified, it will be output to the template instead.
output_to_template
 
If included the templates will be output directly to the template.
=
prepend:value
 
Prepend the specified templates before the fetched results. All prepended input will be returned in the same order that it is input. Value may one or more templates, a guid, or a string.
append:value
 
Append the specified templates after the fetched results. All appended input will be returned in the same order that it is input. Value may one or more templates, a guid, or a string.
exclude:value
 
Prevent the specified templates from being included in the fetched results. Has no affect on prepended and appended items. Value may one or more templates, a guid, or a string.
exclude_prepended:true
 
Specifically exclude all prepended templates from the fetched results. If "unique:true" is specified this is the default behavior, although you may also specify "exclude_prepended:false" to allow any prepended items to be fetched along with other results anyway.
exclude_appended:true
 
Specifically exclude all appended templates from the fetched results. This is false by default - even if "unique:true" is specified - so that results are returned in the proper order.
unique:true
 
If set to true, each of the resulting lists (prepended, fetched, appended, and items) will be unique, although there may be duplicates between the prepended, fetched, and appended lists. The "items" list will include objects in the order in which they appear - with prepended items first, then fetched items, then appended items.
max_size:number
 
If specified, then the "items" list will only include up to the specified number of templates. The "limit" may be automatically lowered to only fetch the maximum number of articles that will be included in "items" following prepended items. Note that this may also impact both the "page" and "total_pages" values. In order to use pagination with a list loaded using "max_size" use "start" instead of "page" and "limit".
%}

Examples

Dynamically Include Template from a Select List

Copy
{% if page.page_layout.is_valid %} {% endif %}

Dynamically Include Template from a Select List

Copy
{% if page.page_layout.is_valid %} {% endif %}

Dynamically Include Multiple Templates from a Select List

Copy
{% if page.sidebar_sections.count > 0 %} {% for section in page.sidebar_sections.selected %} {% include section %} {% endfor %} {% endif %}

Checkbox Include Partial Template

Copy

Show Sidebar? {{ page.show_sidebar }}

{% if page.show_sidebar.checked %} {% include "Sidebar" %} {% endif %}

Inline javscript from template

Copy
OR {% javascript js = "/javascript/inlined/blog" %} {% if js is_valid %} {% endif %}

Dynamically Include Template

Copy
{% var dynamicTemplate = "/partials/footer-main" %} {% include dynamicTemplate %}

Include template and pass variables

Copy
{% search searchCollection "keyword" limit:10 page:search-page %} {% for result in searchCollection %} {% include "search-result" item:result %} {% endfor %} {% include "pagination" collection:searchCollection style:"links" max_links:5 %}