Introduction
Basic Concepts
Understanding Routing
Intercepting Requests
Module Fundamentals
Database Operations
Templates
Helpers
Form Handling
Form Validation
Working With Files
Image Manipulation
Working With Dates & Times
Language Control
Authorization & Authentication
Building Custom HTML Templates
The built-in admin() and public() templates cover most cases, but sometimes you need something completely different that will be reused across many pages.
Typical examples:
- A private members-only area with its own header, sidebar and footer
- A documentation site with a custom left-hand navigation
- An invoice or ticket printing layout
- A minimal “coming soon” or maintenance page
In Trongate v2 you have two equally good ways to create your own templates. Pick the one that feels natural for your project.
Option 1 – Add to the Existing templates Module (most common)
Let’s say we are building a private members’ area that has its own layout (different header, different navigation, maybe a dark color scheme). We want to reuse this layout on dozens of pages.
Step 1 – Add a new method
Open modules/templates/Templates.php and add:
Step 2 – Create the template view file
Create the file:
This is a full HTML page – just remember to include this line exactly where your page content should appear:
Step 3 – Use it anywhere
That’s it. No config, no registration, no fuss.
Option 2 – Create a Completely Separate Template Module
Use this when you want a totally self-contained, reusable design (for example, a modern admin theme you plan to reuse on multiple projects).
Step 1 – Make the module
Step 2 – Write the controller (copy-paste ready)
Step 3 – Use it exactly like any other module
Where to Put CSS, JS and Images
Usually, templates will require CSS files and/or JavaScript files. Sometimes they might also contain other types of assets such as images or fonts. As far as choosing a location for all that stuff goes, you have two options:
- Simple: drop them in
public/ - Self-contained (recommended): store them inside the template module and serve via the module assets trigger:
No extra configuration required.
99% of projects only ever need Option 1.
Option 2 is there when you want to copy an entire design to another project in seconds.