The Templates Module
Built with 100% Native PHP, The Templates Module delivers ready-to-use admin and public templates with responsive navigation, theme support, and intelligent asset loading.
Instructions on how to use this module are offered in the Templates Chapter of the Trongate Framework Documentation.
__construct()
Constructor for the Templates module. Calls parent constructor and blocks direct URL access.
admin()
Displays the admin theme template with provided data. This method loads the full admin panel layout, complete with header, sidebar, footer, and mobile navigation. It processes optional theme settings and additional CSS/JavaScript includes before rendering the template. The method automatically injects your view content into the admin layout using the display() helper.
detect_base_url()
Auto-detects the application's base URL by examining the server protocol, host, and script path. Used during initial setup to suggest a likely base URL for the application.
error_404()
Displays the 404 error page. This method is automatically invoked by Trongate when a requested URL cannot be matched to any existing route. It loads the error_404 template view, which provides a user-friendly message indicating that the requested page could not be found. The method can be customized by editing the template view file or by changing the ERROR_404 constant in the configuration file to point to a different module and method.
public()
Displays the public theme template with provided data. This method loads a clean, public-facing layout designed for websites and landing pages. It processes additional CSS/JavaScript includes before rendering the template. The method automatically injects your view content into the public layout using the display() helper. Unlike the admin template, the public template provides a minimal structure, giving you maximum flexibility for front-end design.
save_base_url()
Saves the user-confirmed base URL to the application's config/config.php file. Validates that a URL was provided, ensures it ends with a forward slash, and writes the BASE_URL constant to the config file.
show_url_setup()
Displays the URL setup form and handles URL submission. On a POST request, calls save_base_url() to persist the confirmed URL. On a GET request, auto-detects the likely base URL and presents it to the user for confirmation.