PHP
  Home arrow PHP arrow Page 8 - Template-Based Web Development With patTemplate (part 1)
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? 
PHP

Template-Based Web Development With patTemplate (part 1)
By: Team Melonfire, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2002-05-28


    Table of Contents:
  • Template-Based Web Development With patTemplate (part 1)
  • Hard Sell
  • Message In A Bottle
  • Slice And Dice
  • Music To Your Ears
  • Watching The Clock
  • A Bookworm In The Ointment
  • 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


    Template-Based Web Development With patTemplate (part 1) - A Rose By Any Other Name...
    ( Page 8 of 8 )

    So that's one look - but now how about changing it a little? Let's do away with the link boxes altogether, and have the links appear in neat rows at the bottom...


    <!-- books.tmpl --> <!-- container page --> <patTemplate:tmpl name="main"> <html> <head> <basefont face="Arial"> </head> <body> <!-- header --> <img src="logo.gif" alt="Company logo"> <!-- content --> <patTemplate:link src="review" /> <p><hr> <patTemplate:link src="recommendations" /> <!-- footer --> <hr> <center><font size=-2>All content copyright and proprietary <a href="http://www.melonfire.com/">Melonfire</a>, 2002. All rights reserved.</font></center> </body> </html> </patTemplate:tmpl> <!-- review section --> <patTemplate:tmpl name="review"> <h2>{TITLE}</h2> <p> <img src="{POSTER}" width="100" height="100" alt="Book jacket" align="left">{CONTENT} </patTemplate:tmpl> <!-- reco section --> <patTemplate:tmpl name="recommendations"> <font size="-1">If you liked this title, you might also like:</font> <br> <table width="100%" cellspacing="3" cellpadding="3"> <tr> <patTemplate:link src="recommendations_list" /> </tr> </table> </patTemplate:tmpl> <!-- reco item section --> <patTemplate:tmpl name="recommendations_list"> <td><a href="story.php?id={ID}"><font size=-1>{ITEM}</font></a></td> </patTemplate:tmpl>
    In this case, I've altered three of the templates to remove the tables and list constructs, so that I'm left with a very simple and elegant layout. Since all I'm doing is altering the layout, no changes are required to the PHP script itself; it should function as before.except that, this time, the output will look like this:



    As you can see, patTemplate makes it possible to separate the user interface from the program logic, thereby allowing designers with little or no programming knowledge to alter Web pages quickly and easily. Further, with its ability to nest and repeat chunks of HTML code, it can speed up development time significantly, and also reduce the effort involved in maintaining and modifying a Web application.

    And that's about it for the moment. In this article, you learned why using templates to build a Web application can save you time and effort during the post-release and maintenance phases of a Web project. You saw how the patTemplate system allows you to organize your user interface into separate, modular templates, and dynamically populate them via variable placeholders. You also saw how the patTemplate system allows you to link templates together, and to construct a complete Web page iteratively from atomic units. Finally, you put all those techniques to the test to create two different page layouts merely by altering the appropriate templates, with no changes required to the business logic of the application.

    In the next (and concluding part) of this tutorial, I will be introducing you to some of patTemplate's more advanced features, including the ability to switch individual templates on and off, to create global variables, to automatically have your templates inherit variables from each other, and to create conditional templates and sub-templates. Make sure you come back for that!

    Note: All examples in this article have been tested on Linux/i586 with Apache 1.3.20 and PHP 4.1.0. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!

     
     
    >>> More PHP Articles          >>> More By Team Melonfire, (c) Melonfire
     

       

    PHP ARTICLES

    - 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 ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT