2 Replies Latest reply on Aug 4, 2006 9:48 PM by shibu_narayanan

    Code structure for include

      I would like to here from some experts if there would be any problem in using the cfinclude structure in the below mentioned manner.
      <cfset sSection = ListGetAt(URL.Action,1,".") />
      <cfset sPage = ListGetAt(URL.Action,2,".") />
      <cfset sTest = funcGetHtmlPage(trim(sSection),trim(sPage))>

      <cfif FileExists(expandpath("#sTest#"))>
      <cfsavecontent variable="sPageContent" >
      <cfinclude template="#sTest#" >
      <cfinclude template="header.cfm" >
      <cfinclude template="footer.cfm" >


      The reason why I have used this method is that there are many variables in the included main file (derived from "sTest" and then passed on to sPageContent) which has to be set to the header section... some of such variables are...

      1. Document Title
      2. Page title
      3. Functional title
      4. Breadcrumps

      Hope this makes the sence..

      Can I find someone who has tried with this type of aproach... Can I move one with this... I badly need a expert openion on this and hope I will find it here.

      Any openion will be highly appreciated.


      Shibu Narayanan
        • 1. Re: Code structure for include
          Dan Bracuk Level 5
          If the variables are set in the header section, you might have some of your code in the wrong order. Did it work when you ran it?
          • 2. Re: Code structure for include
            shibu_narayanan Level 1
            Thanks for the reply...
            Earlier I too had the feeling that this won't work... but surpricingly it all went in my way... and I still wonder if anything could go wrong in the later phase.. My main concern is about the performance issues....

            This is how I need ti working...
            The URL will hold the page action which will derive the include file for the particular action.
            I need my main page (the dynamic include file) to set some values to the header file ("header.cfm").
            If I go for including the files in the conventional order I may have to get some other initializing file included before everything... or some extra code running for that..
            No that Im executing my main page first I can have the all my data required for the main file into some variables and then place it on the header file or to any other part of my web page...

            It all came to my Idea on seeing the fusebox architecture where I was able to set my header text from any section of the code.. (I havents looked into the fusebox code)...
            Would like to know if there is a ny other way if I can do this....

            Thanks & Regards
            Shibu Narayanan