Display Tutorials

  Home arrow Display Tutorials arrow Page 3 - Writing a Template System in PHP
DISPLAY TUTORIALS

Writing a Template System in PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 69
    2004-01-13

    Table of Contents:
  • Writing a Template System in PHP
  • The Implementation
  • The Template File
  • The Class Skeleton
  • Constructor and Output
  • Replacing Tags
  • Including Dynamic Files
  • The Final Code
  • Tricks

  •  
     

    SEARCH CODEWALKERS

    Writing a Template System in PHP - The Template File


    (Page 3 of 9 )

    Before I could start scripting my templating engine I first needed a template file. Not only would the template file be the cornerstone of the entire site, but it would also dictate how the class should be written.

    Though I could have chosen any set of characters to delimit my placeholders, I chose braces because they seem to be the ones most commonly used in other templating scripts. This would hopefully make template file sharing easier in the future.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html>
      <head>
        <title>{title}</title>
        <meta http-equiv="Content-Type" 
              content="text/html; charset=iso-8859-1" />
        <link rel="stylesheet" href="css/mystyles.css" 
              type="text/css" />
      </head>
      <body>
        <div id="banner">
          <img src="images/logo.png" alt="Main Logo" />
          <div id="menubar">
            {menu}
          </div>
        </div>
        <div id="leftcol">
          {left}
        </div>
        <div id="rightcol">
          {right}
        </div>
        <div id="main">

          {main}
        </div>
        <div id="footer">
          {footer}
        </div>
      </body>
    </html>

    More Display Tutorials Articles
    More By bluephoenix

    blog comments powered by Disqus

    DISPLAY TUTORIALS ARTICLES

    - Smart Auto Refresh
    - Writing a Template System in PHP

    Developer Shed Affiliates

     



    © 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap