Brent,
Thank you for your reply. If I added this line to my template's css file, would the css file need to change to a php file? Or would the line go in my page template file?
drupal_add_css(path_to_theme() . '/' .theme_get_setting('banners').'.css', 'theme', 'all');
Thank you, Tracey
Quoting Brent Hardinge brent@hardinge.net:
It seems that in order to get the css into the system, you need to use drupal_add_css outside of the preprocess function because it is the template_preprocess_page function that is used to add the css to the $variables['styles'] function.
So what I would recommend doing is adding the following at near the top of your template.css file:
drupal_add_css(path_to_theme() . '/' .theme_get_setting('banners') .'.css', 'theme', 'all');
That should replace your switch function and print the appropriate css file based on the settings.
Cheers, Brent
Design / Interaction / Strategy http://brenthardinge.net
On Mon, Nov 9, 2009 at 10:00 AM, Tracey Hummel thummel@email.arizona.edu wrote:
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@uainfo.arizona.edu
themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes