PHP
  Home arrow PHP arrow Working with Multiple Template Files t...
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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

Working with Multiple Template Files to Separate Logic from Presentation
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2006-05-16

    Table of Contents:
  • Working with Multiple Template Files to Separate Logic from Presentation
  • Setting up the basics of chunked caching: defining multiple template files
  • Parsing multiple template files: redefining the “TemplateProcessor” class
  • Putting the “TemplateProcessor” class to work: setting up a concrete example

  • 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

    Working with Multiple Template Files to Separate Logic from Presentation
    (Page 1 of 4 )

    Welcome to the last part of the series “Separating logic from presentation.” In three tutorials, this series teaches you how to develop an expandable template processor class using PHP 5, which exposes some useful features, such as recursive placeholder replacement, MySQL result sets processing, and parsing of dynamic PHP files, among others.
    A downloadable file for this article is available here.

    Introduction

    As you’ll hopefully recall, in the previous article I set up an illustrative hands-on example, aimed at demonstrating the functionality of the “TemplateProcessor” class that I wrote at the beginning of the series. With reference to this example, I created some basic dynamic PHP files, aside from fetching a small MySQL result set, and finally integrated all these data sources within an array of input tags, in order to show how the template processor class was capable of parsing a given template file.

    Although the sample PHP files that I included as elements of the respective array of input tags were rather basic, they allowed me to illustrate the way that the “TemplateProcessor” class replaces the placeholders in question with data coming from different data sources. As I said repeatedly over the previous tutorials, the structure of this class is very expandable, thus if you need even more template processing features, in accordance with your particular development requirements, you can easily add more methods to the class, or rewrite the existing ones.

    Now, by returning to the subject of this last installment, I’ll use the skeleton of the original “TemplateProcessor” class to develop an improved, production-level template processor, which, as you’ll see in a few moments, will be capable of working with multiple template files, in addition to implementing a chunked caching system. In this way, the class will be able to use several templates that have distinct cache expiration times, aside from utilizing most of the template processing features that you learned before.

    Are you ready to start learning how to code this improved template processor? Right, let’s do it together.

    More PHP Articles
    More By Alejandro Gervasio


       · Over the course of this article, you'll learn how to build a powerful template...
       · Hi, first of all great article.I am having trouble with this line:// clean up...
       · Hey, thank you for the kind comments on this article. Regarding your question, try...
       · USE SMARTY (template engine) and you will bew happy!LOOK...
       · Thank you for your feedback regarding this article. I agree with you that Smarty is...
       · Parse error: parse error, unexpected '{' in...
       · Thank you for your comments on this article. Regarding your question, I used the...
       · My server is running php 4 and PHP 5, i had to name the file...
       · I'm glad to know you fixed out the problem.Thank you again for the kind words on...
       · Awesome tutorial ... I've found this series not only a great primer for learning how...
       · Thank you for your kind words on my PHP article. I really appreciate your comments....
       · First of all thanks for you usefull template engine.Second: I'm not a skilled PHP...
       · Thank you for commenting on my PHP article. Now, you can have a readable version of...
       · Thank you very much for your prompt answer.I also found it by myself 5 minutes...
       · You're welcome Massi. I'm glad to know the problem was solved...
       · Hello Alejandro,thanks for the good tutorial, I have this code on...
       · Hi Roy,Thank you again for the comments on my PHP article. Concerning your...
     

       

    PHP ARTICLES

    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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