Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-30
15
Medium Priority
?
595 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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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