[support] theme settings/conditionally switching css files
Tracey Hummel
thummel at email.arizona.edu
Wed Nov 4 16:34:17 UTC 2009
I want a site administrator to be able to configure a theme and select
different
banners/color combinations by adding a css file based on what they select.
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;
}
}
Is anyone doing something similar and could 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 support
mailing list