Page 1 of 1

[SOLVED] Dynamic tag in CSS?

Posted: Tue Feb 15, 2011 2:55 pm
by jd447
Hi,

I'm wondering if it's possible to insert a UDT or a global content tag in a CSS sheet? (like the [[root_url]]
What i would like to do, is to define a few colors in a tag and then call them in my CSS sheets. It would be very useful then if i would like to change quickly the colors on a website for example.

like that:

.foo {
color: [[color-tag]]
background-color: [[color-tag-two]]
}

What would be the best way to do that?

thanks guys,
jd

Re: Dynamic tag in CSS?

Posted: Tue Feb 15, 2011 5:01 pm
by Wishbone
I've never tried using a UDT or a GCB in a stylesheet, but what I do is add color definitions at the top of the stylesheet:

Code: Select all

[[assign var="plum" value="#B58CB2"]]
[[assign var="cream" value="#FFF7DA"]]
[[assign var="rose" value="#FC5E72"]]
[[assign var="fudge" value="#7A3F28"]]
Then later on, I use those values:

Code: Select all

h1 {
  color: [[$fudge]];
}
This isn't really dynamic content, since they are defined at the top. I know that you can use some Smarty logic and control stuctures in these stylesheets, but I really don't understand how they are cached and have dynamic content at the same time. It just seems to work! :)

Re: Dynamic tag in CSS?

Posted: Tue Feb 15, 2011 5:47 pm
by jd447
thanks! looking fwd to try.

Re: [SOLVED] Dynamic tag in CSS?

Posted: Tue Feb 15, 2011 5:54 pm
by calguy1000
GCB's will work. However they will only be called when the .css file is being generated in the tmp/cache directory. And this only happens on the first request of a page using that stylesheet AFTER the stylesheet has been changed (or the cache cleared).

i.e: you can put [[global_content name='my_css_colors']] at the top of every stylesheet.
and that will work, and will be called exactly once for each stylesheet, and will not be called any more until either the cache is cleared, or the stylesheet is changed again.