Solved

Can a CFM file be set to ignore the application.cfm file?

Posted on 2004-04-30
15
559 Views
Last Modified: 2013-12-24
OK, I am working on a file that will allow for a query to be saved into a csv format and downloaded by the user.  I have everything working fine in a test area, but I realized that in the production area, it is including the footer specified in the application.cfm file.  I moved the file to a sub directory and put a "blank" application.cfm file in there with it and it works fine.  Is there anyway to keep in in the directory I want but have it ignore the application.cfm file?

Here is the code if you are interested:

<!--- Set variables for special characters --->
<CFSET NewLine = Chr(13) & Chr(10)>

<!--- Suggest default filename for spreadsheet --->
<CFHEADER NAME="Content-Disposition" VALUE="filename=test.csv">

<cfcontent type="text/plain">
<cfoutput>"Column1","Column1","Column3"#NewLine#</cfoutput>
<cfloop query="LookupQuery">
<CFOUTPUT>"#Field1#","#Field2#","#Field3#"#NewLine#</CFOUTPUT>
</cfloop>


When it outputs without the blank application.cfm file, I get this output:

"Column1","Column2","Column3"
"Field1","Field2","Field3"
"Field1","Field2","Field3"
"Field1","Field2","Field3"
            </td>
      </tr>
</table>
            </td>
            <td width="10"></td>
      </tr>
      <tr>
            <td height="10" colspan="3"></td>
      </tr>
</table>
</body>
</html>
0
Comment
Question by:Cardguy
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10959859
there is noway to not include the application page.
"
Whenever a template is equested, ColdFusion loos for an application templae in the current directory-the directory that the requested template itself is in. if no application template is found ColdFusion looks in the requested template's parent directory and then gradually up the directory tree, one directory at a time.
"
--Ben Forta
ColdFusion web apllication construction kit 4.0
0
 

Author Comment

by:Cardguy
ID: 10959979
What would happen if I put this CSV generation code in a CFC?  I'm attempting to do that now, but running into a few snags.  If the code is executed from a CFC and the CFC issues the file download prompt, will the application template not be included?
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10960007
what does your application page look like?
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10960026
here is the way I use mine
<cfsilent>
<!---
File name       :: Application.cfm

Author            :: Matt Graf

Date written:: 1/13/2004

Description ::This is the application that gets include in every page
 --->
<cfapplication       name='ATVanirCM'
                        clientmanagement='yes'
                        clientstorage='cookie'
                        setclientcookies='yes'
                        sessionmanagement='yes'
                        sessiontimeout='#CreateTimeSpan( 0,0,90,0)#'
                        applicationtimeout='#CreateTimeSpan(0,5,30,0)#'>
<!--- the config file contains all of the global variables --->
<cfinclude template="assets/system/config.cfm">

 </cfsilent>



what if you put a condition in there
<cfparam name="page" default="">
<cfif page is not  "csv">
<cfsilent>
<!---
File name       :: Application.cfm

Author            :: Matt Graf

Date written:: 1/13/2004

Description ::This is the application that gets include in every page
 --->
<cfapplication       name='ATVanirCM'
                        clientmanagement='yes'
                        clientstorage='cookie'
                        setclientcookies='yes'
                        sessionmanagement='yes'
                        sessiontimeout='#CreateTimeSpan( 0,0,90,0)#'
                        applicationtimeout='#CreateTimeSpan(0,5,30,0)#'>
<!--- the config file contains all of the global variables --->
<cfinclude template="assets/system/config.cfm">

 </cfsilent>

</cfif>
0
 

Author Comment

by:Cardguy
ID: 10960056
Well, funny you should ask.  I have a few.  I'm sure this is the wrong way to go about it, but here is a quick overview.  We are building webapps for a new Intranet Portal.  So, the root of the portal has one application page, then each webapp is in a separate folder within a WebApp folder that hangs off the root.  Each webapp has it's own application page as well, which also references the portal application page.  Basically, we always wanted the portal "wrapper" to be around all webapps.

I see your example that you just posted.  Would I then put a page param of "CSV" in the page that generates the CSV file?
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10960082
here is my email contact me {email address edited out - ee_ai_construct, ee cs mod}
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10960093
<cfparam name="page" default="">
<cfif page is not  "csv">
<cfsilent>
<!---
File name      :: Application.cfm

Author          :: Matt Graf

Date written:: 1/13/2004

Description ::This is the application that gets include in every page
 --->
<cfapplication      name='ATVanirCM'
                    clientmanagement='yes'
                    clientstorage='cookie'
                    setclientcookies='yes'
                    sessionmanagement='yes'
                    sessiontimeout='#CreateTimeSpan( 0,0,90,0)#'
                    applicationtimeout='#CreateTimeSpan(0,5,30,0)#'>
<!--- the config file contains all of the global variables --->
<cfinclude template="assets/system/config.cfm">

 </cfsilent>
<cfelse>
<!--- Set variables for special characters --->
<CFSET NewLine = Chr(13) & Chr(10)>

<!--- Suggest default filename for spreadsheet --->
<CFHEADER NAME="Content-Disposition" VALUE="filename=test.csv">

<cfcontent type="text/plain">
<cfoutput>"Column1","Column1","Column3"#NewLine#</cfoutput>
<cfloop query="LookupQuery">
<CFOUTPUT>"#Field1#","#Field2#","#Field3#"#NewLine#</CFOUTPUT>
</cfloop>


When it outputs without the blank application.cfm file, I get this output:

"Column1","Column2","Column3"
"Field1","Field2","Field3"
"Field1","Field2","Field3"
"Field1","Field2","Field3"
          </td>
     </tr>
</table>
          </td>
          <td width="10"></td>
     </tr>
     <tr>
          <td height="10" colspan="3"></td>
     </tr>
</table>
</body>
</html>
</cfif>
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Cardguy
ID: 10960438
That could work, but the problem is that we want to build it (and I have a semi-working version already) as a CFC that can be used by all the webapps.  So, your cfelse wouldn't work in that situation...I don't think.  But I'm a CF newbie.

BTW, here is my component:

<cfcomponent>
      <cffunction access="public" name="QueryToCSV">
            <cfargument name="Headers" type="string" required="yes" default="" hint="Column Headers, sep. by commas">
            <cfargument name="Fields" type="string" required="yes" default="" hint="Field Names in order of display, sep by commas">
            <cfargument name="QueryContent" type="query" required="yes" default="" hint="the query itself">
            <cfargument name="Filename" type="string" required="yes" default="" hint="name of the output file">
            
            <!--- Set the carriage return for the CSV output --->
            <CFSET NewLine = Chr(13) & Chr(10)>
            
            <!--- Add quotes around content to allow for commas in column names --->
            <cfset revisedheaders = ReplaceNoCase(Headers,",",'","',"ALL")>
            <cfset revisedheaders = '"' & revisedheaders & '"'>
            
            <!--- Add quotes around field names to allow for commas --->
            <!--- Add # around field names so they can be processed by cold fusion as variables --->
            <cfset revisedfields = ReplaceNoCase(Fields,",",'##","##',"ALL")>
            <cfset revisedfields = '"##' & revisedfields & '##"'>
            
            <!--- Suggest default filename for spreadsheet --->
            <CFHEADER NAME="Content-Disposition" VALUE="filename=test.csv">
            
            <cfcontent type="text/plain">
            <cfoutput>#RevisedHeaders#</cfoutput>
            <cfoutput query="QueryContent">#evaluate(dE(revisedfields))##NewLine#</CFOUTPUT>            
      </cffunction>
</cfcomponent>

It is almost working, but I have a few problems wichi I will post as a different question.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10961033
What you could do is to put the code in a different file and then include that as needed in the pages that you do wnat it to run in

That way you don't have to have it is a different directory.
0
 

Author Comment

by:Cardguy
ID: 10961121
Actually, I think I have it working.  When it is in the CFC, it does not include the Application.cfm...since I guess CFCs don't read application.cfm files.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10961255
Glad you have it working.
0
 

Author Comment

by:Cardguy
ID: 10961265
So what do I do with this thread?  Ask for a refund since I figured it out myself?
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 10961266
kewl
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10961342
Yep you post a message here :

http://www.experts-exchange.com/Community_Support/

and ask that the question be PAQ/Refund

Be sure to inlcude a link to this question and also be sure that you have posted the solution in this question or they will not refund the points.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10961608
Request:
http://www.experts-exchange.com/Community_Support/Q_20973827.html

Granted as all agreed, closed question and 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now