[SOLVED] Dynamic tag in CSS?

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
jd447
Forum Members
Forum Members
Posts: 134
Joined: Wed Jun 20, 2007 7:06 am
Location: geneva

[SOLVED] Dynamic tag in CSS?

Post 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
Last edited by jd447 on Tue Feb 15, 2011 5:48 pm, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Dynamic tag in CSS?

Post 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! :)
User avatar
jd447
Forum Members
Forum Members
Posts: 134
Joined: Wed Jun 20, 2007 7:06 am
Location: geneva

Re: Dynamic tag in CSS?

Post by jd447 »

thanks! looking fwd to try.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [SOLVED] Dynamic tag in CSS?

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Layout and Design (CSS & HTML)”