I find it to be a giant pain to keep track of colors in my CSS template, so I would really like a way to define them in one place and then replace the color code (e.g., #698B69) with a meaningful variable name.
So, I thought that parsing the CSS template through EE would allow me to use PHP or, maybe, global variables. However, I can’t seem to figure out how to do this. This knowledgebase article gives two methods. The first is to use a direct link to the CSS template, but that doesn’t send the proper headers and may cause problems in some browsers. I don’t want that. The second method is to define the styles that need to use dynamic variables in the <head> tag. I can do that, but I may as well move the entire CSS template into the <head> tag.
In this post Lisa gives the syntax to use with a path= variable. Here is what I’m using now, and it works but won’t use PHP or global variables:
<link rel='stylesheet' type='text/css' media='all' href="{stylesheet={embed:style}}" />and here is how I tried to implement the code that Lisa posted:
<link rel="stylesheet" type="text/css" media="screen" href="{path={embed:style}}" />This syntax doesn’t work, and I lose all CSS formatting. Even if I replace {embed:style} with the actual path to the CSS template, it still doesn’t work.
Any idea why I can’t get this to work? Or, is there a better way to use variables in my CSS? I’d really like to define the variables at the top of the CSS and then just reference them when needed. That would make my life a bit easier.