pass variables to style.css
peach - January 22, 2008 - 13:45
_phptemplate_variables can be used to pass variables to .tpl.php files only, is that right?
How would I go about passing variables into style.css, assuming I'm parsing my style.css with php, is there a drupal-funcation that I can use with this?
If not, is it possible with some non-drupal php code?
thanx in advance,
JR

You can't use variables in your CSS files
You can't actually use variables within your CSS files as such. Instead you generally assign classes/ids to your markup based in variables - and then assign style to these classes/ids in your stylesheet.
A good example of this is in the node tempalte, where a new class is put onto the wrapping div is the node is 'unpublished' and then CSS is used to change the background colour accoridingly.
Mike,
Computerminds offer Drupal development, consulting and training
The problem is that in some
The problem is that in some of my themes I offer some optional widgets that use quiete some css by themselves, with drupal as it is now you have 2 choices:
-adding the optional css to your page as inline styles, thus adding overhead to all your pages
-adding a stylesheet with the relevant styles when an option is activated, thus adding many http requests to your theme
Option one wastes bandwidth because css files are not cached.
Option 2 _can_ be a good option, if you can aggregate stysheets, but thats only for sites with public file system. Furthermore, most drupal users will probably leave the css aggregation turned off once they find out their theme is working.
Neither option is good practice.
What I want to do is ship my theme with a .htaccess file that tells apache to let php parse style.css and use logic within the theme to pass styles efficiently.
-------------------------------
peach from All Drupal Themes
Yes you can parse the css file with PHP
Yes you can parse the css file with PHP but I would not recommend it. Once you do that the browser can no longer cache the css styles and what might seem like it would improve performance becomes a performance hit.
The browser will still be
The browser will still be able to cache the stylesheet, why would the browser treat it any differently?
The style.css would only change as frequent as a regular website it's stylesheet being manually updated...
-------------------------------
peach from All Drupal Themes