Search code examples
drupaldrupal-distributions

Change color-schema in Drupal install profile


How can I change the used color-profile in my Drupal install profile? I've installed the colors-module and I can configure under Appearance - Settings - *theme* my color-schema which results in a $info array with all the color values. But how can I place this in my install profile so it will be installed by default?

I have added a task in my install profile and linked to it this function. But obviously, there is something missing...

$tasks['_create_color']['display_name'] = 'Set the typical color on each platform';
$tasks['_create_color']['display'] = 0;

function _create_color() {
    $info = array(
    'schemes' => array(
    'default' => array(
      'title' => t('Blue Lagoon (default)'),
      'colors' => array(
        'top' => '#97279b',
        'bottom' => '#97279b',
        'footer' => '#97279b',
        'link' => '#97279b',
      )
    )));
}

Anyone with advice?


Solution

  • I found myself a perfect function to change the used color-profile!

    function _create_color() {
        $theme = 'bartik';
        $scheme  = 'firehouse';
    
        $fform = array();
        $fform_state = array();
    
        $fform_state['build_info']['args'][0] = $theme;
        $fform = system_theme_settings($fform, $fform_state, $theme);
    
        color_form_system_theme_settings_alter($fform, $fform_state);
    
        $fform_state['values']['theme'] = $theme;
        $fform_state['values']['info'] = color_get_info($theme);
        $fform_state['values']['palette'] = $fform_state['values']['info']['schemes'][$scheme]['colors'];
        $fform_state['values']['scheme'] = $scheme;
    
        color_scheme_form_submit($fform, $fform_state); 
    }
    

    Which does the trick when placed inside a task in the install profile.