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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PHP

Web Development With PHP FastTemplate
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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 file include("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 feedback on 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

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek