Solved

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

Posted on 2004-04-30
15
544 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
Comment Utility
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
Comment Utility
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
Comment Utility
what does your application page look like?
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
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
Comment Utility
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
Comment Utility
here is my email contact me {email address edited out - ee_ai_construct, ee cs mod}
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
<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
Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

 

Author Comment

by:Cardguy
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad you have it working.
0
 

Author Comment

by:Cardguy
Comment Utility
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
Comment Utility
kewl
0
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

12 Experts available now in Live!

Get 1:1 Help Now