The following custom Twig functions can be used within content type templates (Themes > Content templates):
listing_path(component_name)
Outputs the path to a first listing content type of the specified component.
Example: {{ fn.listing_path('m_news_articles') }}
Sample output: /news/
content_path(content_id)
Outputs the path to a specific content, including an anchor link.
Example: {{ fn.content_path('123') }}
Sample output: /pagex/#c123
page_path(page_id)
Outputs the path to a specific page.
Example: {{ fn.page_path(234) }}
Sample output: /pagex/
add_page_class(class_name)
Adds the specified class name(s) to the page's body element.
Example: {{ fn.add_page_class('my-class') }}
set_page_class(class_name)
Sets the page's body element with the specified class name(s) and removes any previously set class name(s).
Example: {{ fn.add_page_class('my-class') }}
template(template_id_or_title)
Outputs the content of another template. The template has the content type's variables applied to it.
Example: {{ fn.template('Template title') }}
log_out_href(page_id)
Outputs the href of the log out controller script. If a page ID is specified then the customer is redirected to the page after logging out.
Example: {{ fn.log_out_href(123) }}
set_content_layout(layout)
Sets the page with the specified content layout.
If no layout is specified then the function will output a table of all available layouts.
Example: {{ fn.set_content_layout('Right sidebar') }}
content(attributes_json)
Outputs the processed HTML of any content type.
Examples: {{ fn.content('{"content_id":123}') }} {{ fn.content('{"page_id":234,"area":"Right sidebar"}') }}
The attributes JSON string accepts the following properties:
-
content_id- Outputs the content specified by the ID -
page_id- Must be used in combination with the area attribute. Outputs the content of a specific page's content area. -
area- The name of a content area e.g. "Right sidebar".
This function can also be used in page templates (Themes > Templates).
img(title)
Outputs the src of an image from the Themes > Images component.
Example: {{ fn.img(logo.gif) }}
This function can also be used in page templates (Themes > Templates).