leafTwig

The flexible, fast, and secure template engine for PHP

Elements CMS support the Twig templating languagearrow-up-right.

Date Format Example

The following example uses the date–modify Twig Syntaxarrow-up-right to format the date, using the DateTimeInterface in PHParrow-up-right.

{{item.date_published|date("j F  Y")}}
circle-exclamation

International Date Formatting

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?