Changing Color Schemes
The built-in admin template ships with multiple color schemes (default, blue, red, green) and switching between them is ridiculously simple.
At a Glance
There are two ways to set the admin theme:
- Per-controller - Set the
$admin_themeproperty on your admin controller (recommended for the built-in admin panel). - Per-method - Pass
$data['theme']directly to$this->templates->admin()(useful for custom controllers or dynamic themes).
Per-Controller (Recommended)
The Trongate_administrators controller (and any controller that extends it) supports the $admin_theme property. Set it once at the top of your controller and it will apply to every admin view automatically:
class Trongate_administrators extends Trongate {
private string $admin_theme = 'blue'; // or 'red', 'green'
// …remaining controller code…
}That's it. Every admin page - manage, create, show, delete_conf, update_password, not_found - will receive the theme automatically. An empty string (the default) produces the default dark charcoal theme.
Per-Method (For Custom Controllers)
If you are building your own controller (not extending the admin panel), 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);
}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;
--primary: #6b21a8;
--primary-dark: #581c87;
--primary-darker: #3b0764;
/* 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 = $_SESSION['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!
We're continually improving the Trongate documentation. If anything is incorrect, unclear, incomplete, or could be better, we'd genuinely appreciate your input.
Share your thoughts in the Documentation Feedback.