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
Changing Color Schemes
The built-in admin template ships with multiple color schemes (default, blue, red, green) and switching between them is ridiculously simple.
How It Works
Just add a theme key to your $data array:
public function manage(): void {
$data['page_title'] = 'Manage Products';
$data['theme'] = 'blue'; // or 'red', 'green', or any custom theme you create
$this->templates->admin($data);
}
That’s it. One line.
What Happens Behind the Scenes
In modules/templates/Templates.php the admin() method does this:
public function admin(array $data): void {
$data['theme'] = (isset($data['theme'])) ? $data['theme'] : 'default';
// …additional includes processing…
$this->display('admin', $data);
}
Then inside modules/templates/views/admin.php you will find:
<body class="theme-<?= $theme ?? 'default' ?>">
The result: the <body> tag gets class="theme-blue", class="theme-red", etc.
The Built-In Themes
The default admin.css already contains these ready-to-use themes:
default– dark charcoal (the original look)blueredgreen
Creating Your Own Theme
Want purple, orange, or a high-contrast mode? Just add a new CSS block to modules/templates/css/admin.css:
body.theme-purple {
--header-bg: #581c87;
--footer-bg: #581c87;
--sidebar: #6b21a8;
--submenu-bg: #581c87;
--submenu-hover-bg: #6b21a8;
/* copy and adjust as many variables as you like */
}
Then use it exactly the same way:
$data['theme'] = 'purple';
$this->templates->admin($data);
No registration. No config files. No recompiling.
Per-User Themes (Real-World Example)
public function dashboard(): void {
$user_theme = $this->session->get('preferred_theme') ?? 'default';
$data['theme'] = $user_theme;
$this->templates->admin($data);
}
Why This Rules
One line of PHP + one CSS block = instant theme switch.
That’s the Trongate way!