SunQuest
 
       PHP
  Home arrow PHP arrow 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 
Actuate Whitepapers 
VeriSign Whitepapers 
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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Web Development With PHP FastTemplate


    (Page 1 of 9 )

    If you've worked with PHP, JSP, ASP or any other tag-based scripting language, you already know that one of the most powerful features of these languages is the ability to combine regular HTML code with programming constructs like variables and function calls. By substituting variable "placeholders" for actual content in an HTML page, these languages make it easy to construct dynamic Web pages; simply alter the values of the variables embedded within the HTML code, and the content displayed on the page changes appropriately.

    As any software designer will tell you, however, this convenience comes at a price - most PHP scripts are so closely interwoven with HTML code that maintaining them is a nightmare. Since both the HTML user interface elements and the program logic are in the same physical file, it becomes difficult for users with no programming experience to modify one without affecting the other. The most common example of this is when interface designers need to alter the look and feel of a particular Web application; typically, the changes they make to the HTML code must be monitored by a developer to ensure the integrity of the remainder of the script.

    As you might imagine, having a developer hand-hold an interface designer through an interface re-design process is annoying to both parties concerned, not to mention expensive to the organization as a whole. A simpler alternative would be to somehow separate the interface (HTML code) from the programming routines (PHP, Perl et al), such that each could be modified independent of the other; this would allow designers to do what they do best, and developers to sleep nights without worrying about the likely repercussions on their beautifully-handcrafted software routines.

    Which brings us to FastTemplate... {mospagebreak title=When Time Is Money} FastTemplate - the PHP version - is actually a port of a well-known Perl module. It is designed, in the author's words, to "manage templates and perform variable interpolation", and is packaged as a single PHP class which can be easily included in your application.

    FastTemplate uses "templates" to simplify maintenance of PHP code, and to separate data from page elements. It assumes that a single Web application is made up of many smaller pieces - it calls these parts "templates" - and provides an API to link templates together, and to fill them with data.

    In FastTemplate lingo, a "template" is simply a text file, typically containing both static elements (HTML code, ASCII text) and FastTemplate variables. When FastTemplate reads a template file, it automatically replaces the variables within it with their values. These values may be defined by the developer at run-time, may be read from another file, or may be extracted from a database.

    As you will see, FastTemplate also makes it possible to "nest" one template within another, adding a whole new level of flexibility to this template-based method of doing things. By allowing you to split up a user interface into multiple smaller parts, FastTemplate adds reusability to your Web application (a template can be used again and again, even across different projects) and makes it easier to localize the impact of a change.

    Before proceeding further, you should visit the FastTemplate home page at http://www.thewebmasters.net/ and download a copy of the latest version (1.1.0 at the time of writing). The package contains the main class file, a document outlining the exposed methods and variables, and some example scripts.

    FastTemplate was originally written for PHP3; if you're using PHP4, you'll need to patch it by making a couple of modifications to the class file. A list of the changes is available on the FastTemplate Web site.

    More PHP Articles
    More By icarus, (c) Melonfire


     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





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