Change default Colour Scheme/layout/sub theme for all users?

I have a custom sub-theme for a suitecrm installation. Is it possible to change the default sub theme for all existing users or force all users to use a different theme (either through php scripts or mysql)?

Thanks

FYI, I found where the sub-theme is stored in the DB.

# SELECT contents FROM `user_preferences` WHERE category='global' ORDER BY `date_modified` DESC
# The contents field contains an md5 string which is a php array
# use unserialize(base64_decode('md5_string')); to get the array
# modify the subtheme key/value pair E.G. [subtheme] => Dawn
# base64_encode the array and serialize it. 
# Update the DB entry
# do a repair/build from admin center (I wonder if this can be done through cmd line or a curl function...?)

I haven’t had the time to write the code and test my theory, but I think it will work. I’ll report back when I try it.

1 Like

Modify custom/themes/SuiteP/themedef.php
For example I’m using “Day” as default and disabled the “Dusk” and “Night” by commenting their lines:

<?php

if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}

global $app_strings;

$themedef = array(
    'name' => 'Suite P',
    'description' => 'SuiteCRM Responsive Theme',
    'version' => array(
        'regex_matches' => array('.+'),
    ),
    'group_tabs' => true,
    'classic' => true,
    'configurable' => true,
    'config_options' => array(

        'display_sidebar' => array(
            'vname' => 'LBL_DISPLAY_SIDEBAR',
            'type' => 'bool',
            'default' => true,
        ),
        'sub_themes' => array(
            'vname' => 'LBL_SUBTHEME_OPTIONS',
            'type' => 'select',
            'default' => 'Day', //HERE GOES THE DEFAULT SUBTHEME
        ),
    ),
);

if(!empty($app_strings['LBL_SUBTHEMES'])) {
    // if statement removes the php notice
    $themedef['config_options']['sub_themes']['options'] = array(
        $app_strings['LBL_SUBTHEMES'] => array(
            'Dawn'  => $app_strings['LBL_SUBTHEME_OPTIONS_DAWN'],
            'Day'   => $app_strings['LBL_SUBTHEME_OPTIONS_DAY'],
            //'Dusk'  => $app_strings['LBL_SUBTHEME_OPTIONS_DUSK'], // DISABLED SUBTHEME
            //'Night' => $app_strings['LBL_SUBTHEME_OPTIONS_NIGHT'], // DISABLED SUBTHEME
        ),
    );
    $themedef['config_options']['sub_themes']['default'] = 'Day';   //HERE GOES THE DEFAULT SUBTHEME TOO
}

This will work with new users. Older users need to modify the profile to select the right subtheme under Layout options.

Thanks,

1 Like

I tested what you did and it seemed to work fine, except that when I reload my page, old theme is stil applied…
My css is all broken and I can’t find any way to get it back.
I did repair and quick repair but it’s still broken.
Could you please help me ?
I’m in a big stress now…
Thanks

You may have a look at this plugin …

https://store.outrightcrm.com/product/suitecrm-theme-style-builder/

Thanks for your answer but for now that’s not what I’m looking for.
I was able to create my own theme and subtheme.
However for some reason when I look at the html code, it seems the page tries to load the older css (SuiteP) instead of mine.
And for some reason, this theme doesn’t load…

Actually I had a closer look and what happens is :
it tries to load my theme and subtheme from cache, but it seems nothing is in the cache…
I don’t understand why.
How is that the css is not in cache ?

Finally i understood :
The css file WAS in the cache folder.
My issue was a problem of file permissions.
I renwed file permissions on cache folder recursively and it’s ok now :slight_smile: