Question about using templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmorand
    New Member
    • Sep 2007
    • 219

    #1

    Question about using templates

    I'm trying to figure out how to use coldfusion templates. I thought I could setup a template and define all the variables I need and the template page would inherit the values from the declaration. Obviously that isn't the case because I'm getting errors on my page that "Title" and "FooterTitl e" are undefined.

    Here is test.cfm:
    [code=cfm]
    <CFMODULE TEMPLATE="/templates/template.cfm"
    Title="Test Title"
    FooterTitle="Te st Footer Title">
    [/code]

    Here is template.cfm:
    [code=cfm]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <head>
    <title>System Access Request</title>
    <link rel="stylesheet " type="text/css" href="css/style.css" />
    <script type="text/javascript" src="../js/jstoolkit.js"></script>
    </head>

    <body onload="loadSec Vars()">
    <!---<cfparam name="Title" default="Title App">
    <cfparam name="FooterTit le" default="Footer App">--->

    <!-- Removed Time from Field
    <cfset #DateTime# = #DateFormat(Cre ateODBCDateTime (Now()),"mm-dd-yyyy")# & " " & #TimeFormat(Cre ateODBCDateTime (Now()),"HH:mm: ss")#>
    -->
    <cfset #DateTime# = #DateFormat(Cre ateODBCDateTime (Now()),"mm/dd/yyyy")#>

    <!-- Container Begins -->
    <div id="container" >
    <cfoutput><h3># Title#</h3></cfoutput>

    <!-- Footer Begins -->
    <div id="footer">
    <cfoutput><di v id="appTitle">< p><a href="./mainMenu.cfm"># FooterTitle#</a></p></div></cfoutput>
    <div id="copyright"> <p>Copyright &copy; 2007 - HealthAlliance Hospital</p></div>
    <!-- Footer Ends -->
    </div>
    <!-- Container Ends -->
    </div>
    </body>
    </html>
    [/code]
  • timselena
    New Member
    • Dec 2007
    • 5

    #2
    You should not really use cfmodule, it's pretty much more for using custom tags. Although you can use it to include page templates as well, but the difference between cfmodule and cfinclude is for cfmodule, it does not share variables between caller page and sub pages, all the values you want to operate on must be passed in as attributes.

    However, cfinclude DOES share variables between them. So in your case, I think you should really use cfinclude instead.
    Last edited by acoder; Apr 2 '12, 11:13 AM.

    Comment

    • dmorand
      New Member
      • Sep 2007
      • 219

      #3
      Thanks, thats a good idea. I'll use CFINCLUDE instead

      Comment

      Working...