Available Variables

ThemeService injects template variables into every view. This reference documents all variables available in each template.

Global Variables (All Templates)

VariableTypeDescription
site_namestringSite name from settings
site_taglinestringSite tagline from settings
page_titlestringCurrent page title
current_urlstringFull current URL
localestringActive locale code (e.g., en)
clsobjectCSS class mapping from theme_info.json
theme_optionsobjectCurrent theme option values
lang_switcherarrayAvailable locales for language switcher

home.tpl

  • posts — array of post objects (paginated)
  • pager — CI4 Pager object (render via {! pager !})
  • categories — array of category objects

post.tpl

  • post — full post object
  • comments — array of comment objects (threaded)
  • comment_count — integer
  • categories, tags — arrays
  • author_profile — author profile object (may be null)
  • prev_post, next_post — adjacent post objects (may be null)
  • seo_meta — SEO meta object (description, og_title, og_image)
  • json_ld — JSON-LD structured data string
{% extends "layout.tpl" %}
{% block content %}
<article>
    <h1>{{ post.title }}</h1>
    {! render_content post !}
    {% if author_profile %}{% include "partials/author-card.tpl" %}{% endif %}
    {% include "partials/comments-list.tpl" %}
    {% include "partials/comment-form.tpl" %}
</article>
{% endblock %}

page.tpl

  • page — static page object (id, title, slug, body, status)
  • seo_meta — SEO meta object

category.tpl / tag.tpl

  • category / tag — taxonomy object
  • posts — paginated post objects
  • pager — CI4 Pager object

archive.tpl

  • year, month — integers
  • posts, pager

search.tpl

  • query — the search string
  • results — matching post/page objects
  • pager — CI4 Pager object

cls and theme_options

cls contains the full css_class_mapping object. theme_options contains resolved option values (merged defaults + admin config). Access via dot notation: {{ cls.cls_btn_primary }}, {{ theme_options.footer_copyright }}.