[themes] add color choices to theme and insert a css

Tracey Hummel thummel at email.arizona.edu
Mon Nov 9 18:00:16 UTC 2009


My trying a add page preprocess that will allow site administrators to be able
to configure a theme and choose different banners/color combinations. Based on
what they select, a different css file would be added that would modify the
banners graphics/colors.

I added three choices to the theme's configuration page by adding this to the
theme-settings.php file:


function graphicDesign_settings(&$saved_settings) {
   $defaults = array(
     'banners'              => 'red-blue',
   );
$settings = array_merge($defaults, $saved_settings);

   $form['banners'] = array(
     '#type'    => 'select',
     '#options' => array(
                'red-blue' => 'Red/Blue',
                'blue-gray' => 'Blue/Gray',
                'white-gray' => 'White/Dark Gray'),
     '#default_value' => $settings['banners'],
     '#title'   => t('Choose a Banner Color Combination'),
    );
return $form;
}


In the template.php file, I'm trying to use the variable passed to add a css
file based on what they select.  In the template.php file:

function graphicDesign_preprocess_page(&$vars) {
   $banners = theme_get_setting('banners');
   drupal_set_message(print_r($banners,true));

   switch($banners) {
     case ("white-gray"):
       drupal_add_css(path_to_theme() . '/white-gray.css', 'theme', 'all');
       break;
     case ("blue-gray"):
       drupal_add_css(path_to_theme() . '/blue-gray.css', 'theme',  'all');
       break;
     default:
       drupal_add_css(path_to_theme() . '/red-blue.css', 'theme', 'all');
       break;
   }
}

The css is not being added.  Is anyone doing something similar and would be
willing to help me?

Thanks,
Tracey

--
Tracey Hummel
Web Developer
University Information Technology Services
Learning Technologies Services
University of Arizona
(520) 626-5139
tracey at uainfo.arizona.edu







More information about the themes mailing list