menu_book Navigation menu

Template Context (Global Variables)

Whenever a controller passes data to a view using render_template(), Pragma CMS automatically injects a strictly defined Global Context. Whether you are using Twig or Native PHP, you have immediate access to the state of the application through three primary objects.

site (The Global State)

The site object (or $site in PHP) contains the global configuration of the current domain. It is initialized once during the CMS bootstrap.

PropertyTypeDescription
site.namestringThe official name of the website.
site.urlstringThe canonical base URL.
site.langCodestringThe currently active language code (e.g., 'en', 'fr').
site.settingsarrayKey-value pairs of all global settings configured in the Admin.
site.activeThemestringThe folder name of the currently active theme.
site.logoarrayThe media array for the site's default logo.

page (The Request State)

The page object (or $page in PHP) represents the context of the current HTTP request. It is built dynamically by the router and the active controller. This is where your actual content lives.

PropertyTypeDescription
page.entryarrayThe database row of the current content (Article, Product, Static Page). Access custom fields via page.entry.fields.
page.viewDataarrayCustom data injected by your PHP Controller (e.g., fetching a list of latest posts to display on the homepage).
page.currentRoutearrayInformation about the active route, including URL params (e.g., slug).
page.cssFilesarrayCSS files queued by the controller or extensions for this specific page.
page.jsFilesarrayJavascript files queued for this specific page.

logged_user (The Session State)

If a user is authenticated (Admin or Customer), this variable holds their session data. If no user is logged in, it returns null.

PropertyTypeDescription
logged_user.first_namestringThe user's first name.
logged_user.emailstringThe user's email address.
logged_user.role_idintUseful for checking permissions in the view.