As Dave says, you can use cfhtmlhead. However, I would encourage the
outputting of your html template to be the last thing that happens.
This gives you greater control over what's going on (for instance, if
you ever use cfhtmlhead to put css in the head, it will be the last
css file processed, because cf inserts the include at the end of the
head tag, which may or may not be a problem). Here's some rough pseudo
code to explain:
1. DO REQUEST PROCESSING, GET ALL YOUR DATA AND KNOW WHAT YOU ARE
GOING TO OUTPUT
2. SAVE THE OUTPUT CONTENT OF THE MAIN BODY OF YOUR PAGE TO A
VARIABLE, i.e. VARIABLES.mainBody
3. OUTPUT THE PAGE TEMPLATE, SOMETHING LIKE:
<html><head>{logic here}</head><body>#VARIABLES.mainBody#</body>
This is of course extremely rough, but I find doing things this way
around, rather than outputting sequencially down the page, produces
more manageable code. In the example, I only save the content of the
main body, but you can of course modularise things further so that you
might get templates that look like:
<html><head>#VARIABLES.metaData# #VARIABLES.cssIncludes#
#VARIABLES.jsIncludes#</head><body>#VARIABLES.nav#
#variables.mainContent#</body>
But I guess you get the point now.
HTH
Dominic
On 16 July 2010 22:29, Dave Watts <[email protected]> wrote:
>
>> If I just do a single include call in line on the page (from the BODY area)
>> to a module, how can I tell it to write js into the script tag
>> in the document HEAD, in addition to placing the XHTML that the module
>> creates in the BODY of the resulting page?
>
> Use the CFHTMLHEAD tag to write to the document head. You can do this
> anywhere in the request processing as long as you haven't cleared the
> buffer using CFFLUSH.
>
>> That leads me to wonder if the CF engine can be told to process js files
>> with cfcode in them through the cf engine. Not to evaluate
>> the js script but to dynamicly build js script without embeding it in my cfm
>> template files. For some reason I'm averse to putting
>> cfm templates in the js scripts folder.
>
> You can map any extension you want to CF, but as a general rule I
> wouldn't recommend doing this for several reasons. First, it makes
> things confusing. Second, it means that these files are less likely to
> be cached. You can output the appropriate MIME type for JS files using
> the .cfm extension, though.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
> http://training.figleaf.com/
>
> Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
> GSA Schedule, and provides the highest caliber vendor-authorized
> instruction at our training centers, online, or onsite.
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335442
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm