Twig
The flexible, fast, and secure template engine for PHP
Elements CMS support the Twig templating language.
Date Format Example
The following example uses the date–modify Twig Syntax to format the date, using the DateTimeInterface in PHP.
{{item.date_published|date("j F Y")}}International Date Formatting
The Twig International Date Extension is installed, but it requires PHP's intl extension to be installed and enabled on your server to function correctly. Make sure to check your PHP configuration to ensure it is available.
Uppercase Example
If you need to ensure your title is uppercased you could append a pipe and upper text to the item.title tag, like this:
{{item.title}} Outputs: Hello world!
{{item.title|upper}}Outputs: HELLO WORLD!
Generate a Clean Text Excerpt
Shows the first 32 words of the content, with all HTML tags removed for a clean text excerpt.
{{ item.body|striptags|split(' ')|slice(0, 32)|join(' ') ~ ' ...' }}Useful Resources
Last updated
Was this helpful?

