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.
| Property | Type | Description |
|---|---|---|
site.name | string | The official name of the website. |
site.url | string | The canonical base URL. |
site.langCode | string | The currently active language code (e.g., 'en', 'fr'). |
site.settings | array | Key-value pairs of all global settings configured in the Admin. |
site.activeTheme | string | The folder name of the currently active theme. |
site.logo | array | The 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.
| Property | Type | Description |
|---|---|---|
page.entry | array | The database row of the current content (Article, Product, Static Page). Access custom fields via page.entry.fields. |
page.viewData | array | Custom data injected by your PHP Controller (e.g., fetching a list of latest posts to display on the homepage). |
page.currentRoute | array | Information about the active route, including URL params (e.g., slug). |
page.cssFiles | array | CSS files queued by the controller or extensions for this specific page. |
page.jsFiles | array | Javascript 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.
| Property | Type | Description |
|---|---|---|
logged_user.first_name | string | The user's first name. |
logged_user.email | string | The user's email address. |
logged_user.role_id | int | Useful for checking permissions in the view. |