1084

Not a Question, but an observation concerning Admin Themes.

Comments for “Not a Question, but an observation concerning Admin Themes.”
 

Posted by Charles Luck on Sunday 3rd March 2024 at 19:09 GMT

To alter the theme color of the Admin Panels, you have to select a theme directory from among theme directories that each contains a full template file, and a full css file. You do this by changing the color directory name in the config/themes file. By default, it looks like this...
<?php
$admin_theme = [
    "dir" => "default_admin/blue",
    "template" => "admin.php",
];

$themes['admin'] = $admin_theme;
define('THEMES', $themes);

As you can see by default it's "blue".
Just as an experiment, I created a new css directory and a file as such:
"/public/themes/default_admin/css/style.php"

and inside the style.php file, I pasted the full css code from any one of the color theme folders within default_admin(with the exception of the first 3 colors in the :root, they are all exactly the same).

Then, I copied the template file from the same folder and dropped it into the outer folder as well:
/public/themes/default_admin/admin.php

and modified the stylesheet link in that file to look like this...
<link rel="stylesheet" type="text/css" href="<?= THEME_DIR ?>css/style.php">


Notice that the stylesheet is a PHP file, it can contain PHP code, but it has to be a PHP file. Make sure that you state explicitly in the link that the CSS file "style.php" is of type="text/css". And then modify the top of style.php file as follows:
<?php 
    header("Content-type: text/css; charset: UTF-8");
  
  //defaults to blue.  
    $admin_theme_color = 'black';

  //  ADMIN_THEME_COLOR;
    switch ($admin_theme_color): 
        case 'black':
            $primary = "#000000";
            $primary_dark = "#1a1a1a";
            $primary_darker = "#4d4d4d";
            break;
        
        case 'blue':
            $primary = "#4682b4";
            $primary_dark = "#427aa8";
            $primary_darker = "#3d719c";
            break;
        
        case 'gray':
            $primary = "#666";
            $primary_dark = "#555";
            $primary_darker = "#444";
            break;
        
        case 'green':
            $primary = "#47b78e";
            $primary_dark = "#409878";
            $primary_darker = "#3f7f69";
            break;
        
        case 'orange':
            $primary = "#ff5000";
            $primary_dark = "#cc4000";
            $primary_darker = "#993000";
            break;
            
        case 'purple':
            $primary = "#9332c7";
            $primary_dark = "#75289e";
            $primary_darker = "#571e75";
            break;
            
        case 'red':
            $primary = "#de0000";
            $primary_dark = "#ab0000";
            $primary_darker = "#780000";
            break;
      //default to blue. 
        default:     
            $primary = "#4682b4";
            $primary_dark = "#427aa8";
            $primary_darker = "#3d719c";
    endswitch;      
?>
:root {
    --primary:<?= $primary?>;
    --primary-dark:<?= $primary_dark ?>;
    --primary-darker:<?= $primary_darker ?>;
    --primary-color: #fff;
    --secondary: #ff0000;
    --border: #000;
    --alt: #fff;
}
...


Go back to the "config/themes" file, and remove the "/blue" entirely from the "dir" entry of the $admin_theme array.
You won't need to go back there.

Go to the top of the style.php file and modify the value of $admin_theme_color to whatever makes you happy. Also, you can simply add more color themes to the switch statement as needed, and if there is no defined value, it will default to blue' or whatever you choose to do there.

You'll find that you can get rid of the color named directories; they won't be needed. Or, don't change a thing. Whatever makes you happy.
Level One Member

Charles Luck

User Level: Level One Member

Date Joined: 18/06/2023

Posted by djnordeen on Sunday 3rd March 2024 at 21:56 GMT

Good one Charles
Early Adopter

djnordeen

User Level: Early Adopter

Date Joined: 20/08/2021

×