Skip to main content
Participant
June 14, 2006
Question

trouble using cfincludes with multi-folder structure

  • June 14, 2006
  • 3 replies
  • 422 views
We are rebuilding our site using <cfinclude> to pull in standard headers and footers for each page. The headers and footers each have many links in them. How can we deal with the fact that the pages calling the cfincludes are not all at the same level in the folder structure? How can we create one include file for the header and one include file for the footer that can each be used throughout the site regardless of the level in which the calling page is located? Thank you.

Cheers!
James
This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
June 15, 2006
How can we create one include file for the header and one include file for the footer that can each be used throughout the site regardless of the level in which the calling page is located?
Create the one header.cfm and the one footer.cfm. Include them in Application.cfm/OnRequestEnd.cfm or in Application.cfc.

Inspiring
June 15, 2006
Use an absolute path!!

If you header is in called dsp_header.cfm and is in a folder in the web root called _templates, then you can call it like so:-

<cfinclude template="/_templates/dsp_header.cfm">

Notice the forward slash '/' at the beginning this tell CF to start at the web root!!
June 14, 2006
try this

ExpandPath(relative_path)