I've done this successfully, but I don't think there's any advantage to it
over putting a <style> block in a cfinclude.  If fact I think the include is
better -- why?

1. the advantage of the linked stylesheet is that it gets cached on the
client the first time it's called and doesn't have to be downloaded again --
but I found that with a dynamic stylesheet, that was not the case -- the
stylesheet was processed and downloaded on every request

2. if you have errors in the CFML, they will be difficult to debug, because
they won't show up in CF debugging info if the cfm page is called through a
<link> tag

I tested this about year ago, on whatever version of CF was current then, so
I can't say whether all this still holds true.

Robert
________________________
Robert Crooks
Educational Services Technical Lead
Macromedia, Inc


-----Original Message-----
From: Eric Gilbert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 10, 2001 7:08 PM
To: CF-Talk
Subject: RE: CF and custom style sheets



It's pretty a straight forward solution.

1) The code to call the included stylesheet could look something like this
<LINK REL="Style Sheet" TYPE="text/css" HREF="stylesheet.cfm">

regular old html3.2 except for .cfm so that the requested file gets parsed
by cf

2) In stylesheet.cfm
<snip>
                <!--- just to keep things cleanish and debug free --->
        <cfsetting enablecfoutputonly="No" showdebugoutput="no">
                <!--- the real key here --->
        <cfcontent type="text/css">
        h1 {
                font-family:
<cfoutput>#Session.stylesheet.H1.Font-Family#</cfoutput>
                <!--- the session stored style information
                        *Remember To make sure the Session.stylesheet
                         structure is defined before here* --->
        }
</snip>

I used a session structure but you could just as easily use client vars or
application vars.

This is the non locked version obviously <cf_shame onMe="Yes">I know, I
know, shared scope variables need locking....</cf_shame> but this basic
approach should work for you, unless I am totally off the mark as to what
you need.

The browser requests the file like any other file but it doesn't know that
it is a stylesheet unless you use the <cfcontent type="text/css">.

- Eric



> -----Original Message-----
> From: Sean Daniels [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 10, 2001 11:37 AM
> To: CF-Talk
> Subject: Re: CF and custom style sheets
>
>
> On 5/10/01 1:27 PM Scott Weikert wrote:
>
> > <LINK REL="StyleSheet" TYPE="text/css" HREF="style.cfm">
> >
> > I've had some hassles trying to link the page like this... it
> doesn't seem
> > to properly execute the CF code within.
> >
> > Anyone out there tried to do this same thing, and succeeded?
> Input would be
> > most welcome.
>
> Two suggestions:
>
> 1. Make a new style sheet for each option, and use:
>
> <cfoutput>
> <LINK REL="Style Sheet" TYPE="text/css"
> HREF="#attributes.stylesheet#.cfm">
> </cfoutput>
>
> Name you style sheets stylegreen.css, styleblue.css, etc.
>
> OR
>
> 2. Add a mapping in IIS if you can to have CF parse .css files. I've never
> done this, but conceivably it could work... If you have that much
> control of
> your environment.
>
> Obviously option two would be preferable so you don't have to maintain
> multiple style sheets.
>
> - Sean
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to