PHP
  Home arrow PHP arrow Page 4 - Web Development With PHP FastTemplate
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Web Development With PHP FastTemplate
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2001-09-05

    Table of Contents:
  • Web Development With PHP FastTemplate
  • Who Am I?
  • Proofing The Pudding
  • You've Got Mail
  • Repeat Customers
  • Flavour Of The Month
  • A Strict() Master
  • Musical Chairs
  • A Rose By Any Other Name...

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Web Development With PHP FastTemplate - You've Got Mail


    (Page 4 of 9 )

    A great amount of FastTemplate's power, however, lies in its ability to manage more than one template simultaneously. Consider the following HTML page:



    Now, suppose I were to split this up into the following sections,



    and assign each section to a template. This would mean that the header, the main form, and the footer at the bottom could be modified independently of each other - a useful capability to have.

    Here are my templates:

    <!-- begin: header.tpl --> <html> <head> <basefont face=Verdana> </head> <body> <table width=100% cellpadding=10 bgcolor="Black"> <tr><td height=30><b><font color=white>{TITLE}</font></b></td></tr> </table> <!-- end: header.tpl --> <!-- begin: form.tpl --> <p> <i>{INSTRUCTIONS}</i> <p> <div align=center> <table border="0" cellspacing="5" cellpadding="5"> <form action="mailer.php" method="post"> <tr> <td>Name</td> <td><input type="Text" name="name" size="15"></td> </tr> <tr> <td>Email address</td> <td><input type="Text" name="email" size="25"></td> </tr> <tr> <td>Subject</td> <td><input type="Text" name="subj" size="25"></td> </tr> <tr> <td>Comments</td> <td><textarea name="comments" cols="35" rows="8"></textarea></td> </tr> <tr> <td colspan=2 align=center><input type="Submit" value="Send Feedback"></td> </tr> </form> </table> </div> <!-- end: form.tpl --> <!-- begin: footer.tpl --> <div align=center><font size=-2> Everything here is © <a href="http://www.melonfire.com/">Melonfire</a>, 2001. All rights reserved.<br> Read our <a href="tac.html">legal notices</a>, and our <a href="privacy.html">privacy policy</a> </font></div> <br> <table width=100% align=center cellpadding=0 bgcolor="Black"> <tr><td> </td></tr> </table> </body> </html> <!-- end: footer.tpl -->
    And here's the script which puts them together with FastTemplate.

    <? // feedback.php - generate a feedback form using multiple templates// include class fileinclude("class.FastTemplate.php3");// instantiate new object$obj = new FastTemplate("./tmpl/");// assign names for template files$obj->define(array("header" => "header.tpl", "form" => "form.tpl", "footer" => "footer.tpl"));// assign values to FT variables within the template// as an associative array of key-value pairs$obj->assign(array("TITLE" => "Feedback Form", "INSTRUCTIONS" => "Please use the following form to send us your feedbackon this Web site"));// parse template "feedback" and store in handler "result"$obj->parse(ft_header, "header");$obj->parse(ft_form, "form");$obj->parse(ft_footer, "footer");// print contents of handler "result"$obj->FastPrint(ft_header);$obj->FastPrint(ft_form);$obj->FastPrint(ft_footer);?>
    Note that, in this case, FastTemplate is parsing and printing more than one template to create a composite HTML document. Each template may be modified independently of the others, making it easier to alter just the top bar or the form fields, for example.

    More PHP Articles
    More By icarus, (c) Melonfire


     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway