Solved

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

Posted on 2004-04-30
15
591 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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
 

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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

632 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