Using Twig functions in Zenario

Zenario has a pluggable module called a "Twig Snippet". This allows a Zenario site to run server-side executable code that's written in Twig.

Twig is a template engine for PHP. In essence, it supports a subset of the server-side PHP language in which Zenario is written, and runs the code in a controlled environment. Read more about Twig at Zenario 8 and 9 support Twig version 2.

When a plugin is created and placed on a content item, and the content item is viewed, the Twig code in the Twig Snippet is executed and the output is displayed on the page.

All regular Twig language constructs can be used in the code you specify, plus the Zenario-specific functions described below.

Getting started

To write a Twig snippet, a plugin of the Twig Snippet module will need to be in a slot on a Zenario content item.

In the settings of the plugin, you will need some code like this:

<p>The date now is {{ "now"|date("jS F") }} and the time is {{ "now"|date("g:ia") }}.</p>

{% if ze('user', 'email') | escape %}
Your email address is {{ze('user', 'email')|escape}}
{% else %}
You are a visitor.
{% endif %}

A good place to start for learning Twig is