{% content %}

October CMS Documentation Docs

{% content %}

The {% content %} tag will display a CMS content block on the page. To display content block called contacts.htm you pass the file name after the content tag quoted as a string.

___TWIG0___

A content block inside a subdirectory can be rendered in the same way.

___TWIG0___

Note: The Themes documentation has more details on subdirectory usage.

Content blocks can be rendered as plain text:

___TWIG0___

You can also use Markdown syntax:

___TWIG0___

Content blocks can also be used in combination with layout placeholders:

___TWIG0___
    ___TWIG1___
___TWIG2___

# Variables

You can pass variables to content blocks by specifying them after the file name:

___TWIG0___

You can also assign new variables for use in the content:

___TWIG0___

Inside the content, variables can be accessed using a basic syntax using singular curly brackets:

<p>Country: {country}, city: {city}.</p>

You can also pass a collection of variables as a simple array:

___TWIG0___

The collection of variables is accessed by using an opening and closing set of brackets:

<ul>
    {likes}
        <li>{name}</li>
    {/likes}
</ul>

Note: Twig syntax is not supported in Content blocks, consider using a CMS partial instead.

# Setting Contents to a Twig Variable

In any template you can set the contents to a variable with the content() function. This lets you manipulate the output before display. Remember to use the |raw filter to prevent output escaping.

___TWIG0___

___TWIG1___

You may also pass variables to the content as the second argument.

___TWIG0___

# Checking a Content File Exists

The hasContent() function can be used to check if a content exists without rendering the contents. To prevent the rendering of the content, pass the second argument as false and it will return true or false if the content file is found.

___TWIG0___
    ___TWIG1___
___TWIG2___
    <p>Welcome content not found!</p>
___TWIG3___