You keep talking about templates being compiled, if there is an error as you have mentioned this will stop the compile of the template and it will look like it is being complied before the other.
I will say this again, the problem is not when it gets compiled but how you are doing it. And I will be honest you have far too much going on in the Application.cfm, why not put that in the cfml template that pulls up the PDF in the first place? I will ask another question, is this application.cfm in the directory of the template in question, or are you relying on the one in the root of the application? Not that it matters, but might explain why you are doing what you are doing with the counting of each request of the PDF. But you really need to work out why it is trying to compile the PDF as a CFML template, that is what the problem is and until you fix that you need to forget about when and how it compiles the CFML template, because and error is not going to compile anything. Regards, Andrew Scott http://www.andyscott.id.au/ > -----Original Message----- > From: Claude Schnéegans <schneeg...@internetique.com> [mailto:=?ISO- > 8859-1?Q?Claude_Schn=E9egans <schneegans@interneti=71?= =?ISO-8859- > 1?Q?ue.com=3E?=] > Sent: Thursday, 23 June 2011 11:04 PM > To: cf-talk > Subject: Re: application.cfm > > > >>In Claude's original question, it doesn't appear he's using CFCONTENT: > > Yes I am. > Here is a summary of the code in application.cfm: > You can see that the requested file is never executed nor intended to. > The only purpose of the .cfm extension is to force the execution of the > application.cfm Here, the code in application.cfm is only used to count the nb > of times each document was requested. > The advantages of the method are 1. simplicity, 2. it is compatible with > previous documents uploaded with true .pdf and .doc extension prior we > implemented this counting scheme. > The only problem which we didn't figure out at the time is that the template > is compiled BEFORE application.cfm is called. > It could have been AFTER as well and CF would still work the same. > In pure logic, there is no use to compile a template before it is certain it will > be executed. > There are other cases templates are compiled for nothing, ie: > application.cfm verifies a user is logged, if not, it <CFLOCATIONs the user > toward the loggin script, then the template he called is never executed. > CF could have very well been designed so that templates are compiled only if > executed. > Now I know it is not the case. > > <!--- Get the document file name ---> > <CFQUERY NAME="getDoc" > DATASOURCE="#application.applicationName#"> > SELECT docId, > fileName, > localName > FROM docs > WHERE localName = '#listLast(cgi.script_name, "/")#' > </CFQUERY> > <CFIF getDoc.recordCount GT 0> > <CFIF > fileExists("#application.webRootDir#contentDocuments\#GetDoc.localName > #")> > <!--- count nb of time document was opened ---> <CFQUERY > DATASOURCE="#application.applicationName#"> > UPDATE docs > SET nblu = nblu+1 > WHERE docId = #getDoc.docId# > </CFQUERY> > > <!--- send document to the reader ---> > <CFHEADER NAME="Content-disposition" > VALUE='Attachment;filename="#getDoc.fileName#"'> > <CFHEADER NAME="Content-Type" VALUE="application/octet-stream"> > <CFCONTENT TYPE="application/octet-stream" > FILE="#application.webRootDir#contentDocuments\#GetDoc.localName#"> > <CFABORT> > <CFELSE> > <CFSET error = "This file doesn't exist"> </CFIF> <CFELSE> <CFSET error = > "This file doesn't exist"> </CFIF> <CFIF error NEQ ""> <CENTER><IMG > SRC="../images/header.png" > WIDTH="790" HEIGHT="135" BORDER="0" ALT=""> > <CFOUTPUT><H2>#erreur#</H2></CENTER></CFOUTPUT> > </CFIF> > <CFABORT> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ~~~~~~~~~~~| > Order the Adobe Coldfusion Anthology now! > http://www.amazon.com/Adobe-Coldfusion- > Anthology/dp/1430272155/?tag=houseoffusion > Archive: http://www.houseoffusion.com/groups/cf- > talk/message.cfm/messageid:345570 > Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm > Unsubscribe: http://www.houseoffusion.com/groups/cf- > talk/unsubscribe.cfm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345572 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm