« wifime wireless mesh and internet solutions for the hospitality and catering industry
» ColdFusion 301 Redirect

CSS, Usability, Design, ColdFusion

Dynamic CSS using ColdFusion

05.06.08 | Comment?

It’s probably quite a well documented subject already, but just thought I would shed some light on producing dynamic CSS using ColdFusion. Instead of linking to a static stylesheet in your webiste, you can link to a .cfm template and get ColdFusion to produce the CSS code for you, allowing you to switch graphics, colours, fonts etc. all when the stylesheet is loaded in. As an example …

<link rel=”stylesheet” type=”text/css” href=”http://yourdomain.com/css/stylesheet.cfm” / >

Inside the file stylesheet.cfm you would have something similar to below …

<cfoutput>
<cfheader name=”content-type” value=”text/css” />
<cfset fontSize = 11 />
body {font-size:#fontSize#px;}
…….. etc.
</cfoutput>

That’s all there is to it. Very simple but very effective and allows you to use a database, xml files or standard text files to switch your application look and feel dynamically.
One really important line in the code above is the <cfheader> tag. Without this line, Mozilla based browsers, will not render the CSS correctly. IE will render, in it’s lovely quirks mode!
:-)

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

:

:


« wifime wireless mesh and internet solutions for the hospitality and catering industry
» ColdFusion 301 Redirect