Tag Functions

Tag functions are called inside {! !} delimiters and return strings inserted directly into the output without HTML escaping. They bridge the template engine to PHP helper functions.

csrf_field

Renders a hidden CSRF input field for use in forms.

<form method="POST" action="{! site_url "comments/post" !}">
    {! csrf_field !}
    ...
</form>

Output: <input type="hidden" name="csrf_token_name" value="...">

No arguments.

lang

Translates a language key using CI4's lang() helper.

{! lang "Common.read_more" !}
{! lang "Auth.login" !}
{! lang "Widget.no_posts" !}

With a positional parameter (substituted into {0} placeholder):

{! lang "Posts.comment_count" count !}

Multiple parameters:

{! lang "Admin.created_by" author.name post.title !}

site_url

Generates a full URL using CI4's site_url(). Includes the app.baseURL and any configured app.indexPage.

<a href="{! site_url "blog" !}">Blog</a>
<a href="{! site_url "category/news" !}">News</a>

With a variable segment:

<a href="{! site_url post.slug !}">{{ post.title }}</a>

base_url

Generates a URL using CI4's base_url(). Does not include app.indexPage. Use for static assets.

<link rel="stylesheet" href="{! base_url "assets/css/app.css" !}">
<img src="{! base_url "uploads/" post.featured_image !}">

theme_url

Generates a URL to a file inside the active theme's public directory.

<link rel="stylesheet" href="{! theme_url "theme.css" !}">
<script src="{! theme_url "js/app.js" !}"></script>
<img src="{! theme_url "images/logo.png" !}" alt="{{ site_name }}">

Resolves to base_url("themes/{active_theme_folder}/{path}").

widget_area

Renders all widget instances assigned to the named area. Returns the concatenated HTML of all rendered widgets.

{! widget_area "sidebar" !}
{! widget_area "footer-1" !}
{! widget_area "header-banner" !}

The area slug must match a row in the widget_areas table. If the area has no instances, returns an empty string.

post_url

Generates the public URL for a post given its slug.

<a href="{! post_url post.slug !}">{{ post.title }}</a>

Equivalent to site_url("post/" . $slug) using the configured post permalink structure.

category_url

Generates the public URL for a category archive given its slug.

<a href="{! category_url category.slug !}">{{ category.name }}</a>

tag_url

Generates the public URL for a tag archive given its slug.

<a href="{! tag_url tag.slug !}">{{ tag.name }}</a>

render_content

Renders a post or page entity's body content through the content pipeline. Applies shortcode processing, markdown rendering (if the post uses markdown format), and returns safe HTML.

{! render_content post !}
{! render_content page !}

The argument must be a full entity object (not just a string). The result is always sanitised HTML; safe to output without further escaping.