Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 598
  • Last Modified:

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

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
Cardguy
Asked:
Cardguy
  • 6
  • 5
  • 3
  • +1
1 Solution
 
CFDevHeadCommented:
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
 
CardguyAuthor Commented:
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
 
CFDevHeadCommented:
what does your application page look like?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
CFDevHeadCommented:
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
 
CardguyAuthor Commented:
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
 
CFDevHeadCommented:
here is my email contact me {email address edited out - ee_ai_construct, ee cs mod}
0
 
CFDevHeadCommented:
<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
 
CardguyAuthor Commented:
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
 
mrichmonCommented:
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
 
CardguyAuthor Commented:
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
 
mrichmonCommented:
Glad you have it working.
0
 
CardguyAuthor Commented:
So what do I do with this thread?  Ask for a refund since I figured it out myself?
0
 
CFDevHeadCommented:
kewl
0
 
mrichmonCommented:
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
 
moduloCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now