Rendering Logic & Pipeline
Pragma CMS uses a Cascading Resolution Pipeline. This allows you to override any core behavior by simply placing a file with the same name in your site's directory.
1. The Execution Lifecycle
When a URL is requested, the system follows this strict sequence:
- Bootstrapping: The Router identifies the route and sets the $site and $page contexts.
- Controller Resolution: The system looks for the logic file using
resolveCascadingPath().- Search 1:
/sites/[your-site]/pages/[controller].php - Search 2:
/cms-versions/[version]/pages/[controller].php
- Search 1:
- Data Hydration: The controller executes, fetches data via Managers, and populates the
$page->viewData,page→entry,$page->main, etc.. - Final Assembly: The controller calls
render_template("base.php", $page), which wraps everything in the master HTML skeleton.
2. Core System Templates
These files define the structural "DNA" of the CMS and are located in system/templates/.
base.php (The Skeleton)
This is the master HTML skeleton of the entire CMS. Everything rendered by the system ultimately passes through base.php.
- Head Generation: Injects charset, viewport, SEO tags, Canonical URLs, and Hreflang links.
- Asset Queuing: Uses
include_styles()andinclude_scripts()to safely inject CSS/JS, automatically attaching the CSP$GLOBALS['csp_nonce']. - JSON-LD: Automatically injects the aggregated
@graphschema.org data. - Header: Loaded via
renderHeader($page). - Layout Container/ Body Structure: Includes the sidebars (if in Admin) and the Main Content that outputs
$page->header, wraps the content in a<main id="main-content-wrapper">block for WCAG compliance, and outputs$page->footer. - Footer: Loaded via
renderFooter($page).
page.php (Static Renderer)
The default fallback controller for Static and Builder pages. If a static page does not define a custom template_path, the CMS uses this file to output the $page->viewData["title"] and the compiled HTML $page->viewData["content"].
Functional Templates
error.php
A centralized, heavily translated template for handling HTTP errors gracefully (404 Not Found, 403 Forbidden, 500 Internal Error). It outputs human-readable solutions and provides a fallback "Return to Home" button.
recap.php (Submission Feedback)
Injected automatically inside the <main> wrapper of base.php. It checks for the presence of $_SESSION['recap'].
If a user successfully submits a frontend form (Contact, Quote), this template generates a clean, formatted alert box summarizing their submitted data and attached files.
Email Templates (emails/)
Transactional emails (auto-replies, password resets) use a dual HTML/TXT rendering system. The render_email_template() function searches for these files in the Theme first, then falls back to the Core.
Each email is defined by two files to ensure maximum deliverability:
.html.php: The rich-text version (CSS, Logos, Tables)..txt.php: The plain-text version. (Note: If the TXT version is missing, the CMS will automatically generate it from the HTML version using theconvert_html_to_text()utility).
Core Email Templates:
form_auto_reply: The confirmation email sent to the user after submitting a form.form_notification: The alert email sent to the administrators containing the form payload.reset_password: Contains the secure token link for account recovery.update_available: Sent to Platform administrators when a new CMS core version is released.