January 8, 2005
Including CF in a CSS page.
Sometimes, it is just beneficial to include cf code within a css file.
In order to do this first save the CSS file with a .cfm extension, for example style.cfm.
Next, at the top of the css file, add the following cfcontent tage
<cfcontent type="text/css; charset=ISO-8859-1">
The page is then processed by CF, but since the cfcontent sets the page to be served with a text/css mime-type resulting in browsers recognizing the page as css.
Finally, to include the file within your cfm page as follows
<link rel="stylesheet" href="style.cfm" type="text/css" />
A side note is to remember to escape the pound signs within the css page when necessary.
To beat Paul Hastings to it, Unicode is your friend. :)
Posted by: Robby at January 8, 2005 9:55 AMI have included many php codes straight into css without doing any file extension change. I am not sure of the CF cases but I think CSS will just throw out what it have in its belly to the browser. For instance if you link to a php instead of an image source and if the php code have function to rotate through an image directory, it will just do what that PHP does "display the images".
Posted by: Brajeshwar at January 8, 2005 10:15 AMThat's cool and all, but you should really set some headers (with CFHEADER) as well so you don't lose the benfit of caching your CSS. Setting an expires datetime seems to be enough usually. dynamically setting it ahead a day or so is usually enough, unless you know your CSS will not change again and then longer is fine.
Posted by: Doug Gibson at January 8, 2005 1:19 PMThanks for the tip! As someone who builds many variations of CMS tools, I'm always looking for ways to optimize things, and this might be very helpful!
cheers.
Posted by: Nolan at January 8, 2005 1:50 PMnot wanting to sound obtuse or anything, but I can't think of a situation to warrent it...
can I bug you with a "f'instance" ? just to illistrate why?
thanx
barry.b
Hi Barry,
How about a different background picture, or color scheme passed on time of year, different receiving pages, or something else.
HTH,
Anticlue
Finally passed the test
Managing in light of McGregor's Theory X and Theory Y
CMMI
Kicking HIT Leadership Up a Notch
That's just some mumbo jumbo project management BS
Outcomes - The tactic to get to the strategy
Nurse Call, VOIP, and Wi-Fi: Its just cool when things come together!
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
August 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
November 2005
October 2005
September 2005
August 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
Joel on Software
David Ross
Edward Prevost
Martin Fowler
The Health Care Blog
The Tales of Hoffman
The Business Word
Medical Rants
Christina's Considerations
Paul Levy
HIS Talk
Appropriate IT
Candid CIO
RSS feed




