Well, I posted this once, about 2 hours ago, and still don't see it online,
so here it is again...

Here's some snippets of code that show how to use CFHTTP to get include
files.  Not saying this is "the best" method out there, but it works well
for my purposes.  (at one point we were using a graphic place holder for the
navigation tree, hence the reason for capturing/checking the mime type of
the navigation file.)

<cfset sFooterFile = "#App.FooterFile#">
<cfset sHeaderFile = "#App.HeaderFile#">
<cfset sNavFile = "#App.Navigation#?Access=#Session.Security#">

<cfset txtFooter = "">
<cfset txtHeader = "">
<cfset txtNav = "">

<!--- Get the header file --->
<cfhttp url="#sHeaderFile#" method="GET" resolveurl="true"></cfhttp>
<cfif FindNoCase("200",CFHTTP.StatusCode) gt 0>
        <cfset txtHeader = cfhttp.filecontent>
<cfelse>
        <cfset txtHeader = "The request for the header file returned a code
other than OK.<br>The code returned was: <br>#CFHTTP.StatusCode#">
</cfif>

<!--- Get the Footer file --->
<cfhttp url="#sFooterFile#" method="GET" resolveurl="true"></cfhttp>
<cfif FindNoCase("200",CFHTTP.StatusCode) gt 0>
        <cfset txtFooter = cfhttp.filecontent>
<cfelse>
        <cfset txtFooter = "The request for the Footer file returned a code
other than OK.<br>The code returned was: <br>#CFHTTP.StatusCode#">
</cfif>

<!--- Get the navigation file --->
<cfhttp url="#sNavFile#" method="GET" resolveurl="true"></cfhttp>
<cfif FindNoCase("200",CFHTTP.StatusCode) gt 0>
        <cfset txtNav = cfhttp.filecontent>
        <cfset txtNavMime = cfhttp.MimeType>
<cfelse>
        <cfset txtNav = "The request for the Navigation file returned a code
other than OK.<br>The code returned was: <br>#CFHTTP.StatusCode#">
        <cfset txtNavMime="Unknown">
</cfif>

<!---  SNIP --->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
        <title>Sample Page</title>
</head>
<body bgcolor="ffffff">
<!--- Page Layout --->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
        <cfoutput><tr bgcolor="#App.CorpColor#"></cfoutput>
                <td colspan=3 width="100%">
                        <!--- Page Header --->
                        <cfoutput>#txtHeader#</cfoutput>
                </td>
        </tr>
        <tr>
                <cfoutput><td bgcolor="#App.CorpColor#"
width=150>&nbsp;</td></cfoutput>
                <td width=5>&nbsp;</td>
                <td width=645>&nbsp;</td>
        </tr>

        <tr>
                <cfoutput><td bgcolor="#App.CorpColor#" width=100
valign="top"></cfoutput>
                        <!--- Navigation --->
                        <cfif findNoCase("image", txtNavMime) gt 0>
                                <cfoutput><img src="#sNavFile#"
border="0"></cfoutput>
                        <cfelse>
                                <cfoutput>#txtNav#</cfoutput>
                        </cfif>
                        
                </td>

<!---  SNIP --->
                

-----Original Message-----
From: Bruce Holm [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 25, 2001 2:50 PM
To: CF-Talk
Subject: Re: Absolute Path Usage


Hi Shawn,
Would you be willing to post or send me directly a small example of this
method?

Thanks
Bruce

----- Original Message -----
From: "Shawn Grover" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, September 25, 2001 11:51 AM
Subject: RE: Absolute Path Usage


> <cfinclude> can only take relative paths.
>
> To get around this issue with my templates, I used CFHTTP to read the file
> in question (page header and menu), then dump the resulting text to my
page
> in the appropriate locations.  This is nice because CFHTTP uses absolute
> paths, and saves me the hassle of remembering to set all my include files
> correctly, and leaves me free to add directory levels and still have my
> header/menu display as I expected, with no changes.
>
> Hope this helps.
>
> Shawn Grover
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to