1 Reply Latest reply on Feb 4, 2007 11:57 AM by joeDangelo

    Using a single  file as a template for th whole site

      My Application.cfm file has the code that i am using as a template for the rest of my site. On the template, the title section looks like this. <cfif IsDefined('pagetitle')><cfoutput><title>#pagetitle#</title></cfoutput><else><title>Welcom e</title>
      and the title variable is set on the end page. lets just say test.cfm but when i view test.cfm the title is always Welcome. How can i fix this. and this also goes along with my content. On the application.cfm pge i have empty divs. on the test.cfm page i have the same divs only with all the page-relevant information in them, but they never show up. I know that this is how you do it in php. but how do you do it in ColdFusion
        • 1. Re: Using a single  file as a template for th whole site
          joeDangelo Level 1
          Theres a few things you could do here... none of which I think is the perfect solution. It all depends on your preference as well as the needs of your application.

          -- Move your page title code to another file - call it Header.cfm or something along those lines -- and include it in every page after you set the pagetitle variable.

          -- Use Javascript to add the page title to some div at the top of the page when it loads. (not my favorite option here)

          -- Check out the CF tag cfsavecontent. You could save the generated HTML in test.cfm into a variable and output it later. Put your pagetitle code in OnRequestEnd.cfm, which is called AFTER every template is executed. Set your pagetitle variable in test.cfm and save the HTML into a variable, then in OnRequestEnd.cfm output the pagetitle followed by your generated content.