PHP
  Home arrow PHP arrow PHP Fast Template
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

PHP Fast Template
By: Ian Felton
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 15
    2001-07-02

    Table of Contents:
  • PHP Fast Template
  • Assigning templates to objects
  • Assigning variables to FastTemplate objects
  • MySQL Data parsed through FastTemplates
  • Multiple templates: Rows of data into a table
  • Summary

  • 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


    PHP Fast Template


    (Page 1 of 6 )

    First, what is the difference between presentation and logic. Its the difference between dealing with the appearance of an apple and dealing with its genetic code. With web applications, presentation includes HTML tags, basic Javascript such as rollover effects, FLASH and anything else in that vein. Logic includes all of the software written in Python, Perl, PHP, or the p-p-p-particular language of choice which best solves the problem at hand.
    So when writing web applications, why separate the two?

    The simple answer to the question of why presentation should be kept separate from logic is, "It keeps things simple". If presentation wasn't separated from logic around your house, you'd have to be an electrician to replace light-switch covers. The same goes for large-scale web applications. Graphic designers shouldn't need to be software engineers in order to update the fonts in a web page. Separating logic from presentation makes that possible.

    There are many ways to accomplish this, but in this article we are going to focus on one method using PHP and an external class called FastTemplate. This class can be downloaded from: http://www.thewebmasters.net/php/

    Reminder: Sometimes separating presentation from logic is overkill. Determine the scope of your project.

    {mospagebreak title=Placing FastTemplate Variables in HTML Templates} It's very simple to include data from an application's business logic into HTML templates. HTML templates are files consisting of HTML with placeholders for dynamic data.

    Whenever dynamic data needs a place holder in the HTML template, place the variable name between curly braces.

    Ex:

    <HTML> <BODY> {HOUSE} <P> This is a house. </P> </BODY> </HTML>
    The variables can be anything that the FastTemplate class can parse: alphanumeric symbols and the underscore, or {(A-Z0-9_)+} for you reg ex lovers. Always keep these variables descriptive of the data that will fill it. Remember, graphic designers will ideally be editing these templates, so they need to know exactly what is going there. Creating charts that index which templates contain specific variables is useful if the need ever arises to change the names of any of them.

    {mospagebreak title=Including the Fast Template Module in PHP Code} So how does the data get from code into the HTML templates? First, the FastTemplate class file must be included in the PHP code. Accomplish this the same as including any external class file. Here is the code to include the FastTemplate class file in a PHP script:

    <?php include "class.FastTemplate.php3";
    Reminder: Be certain to place the path to the FastTemplate class file into the PHP.ini file's INCLUDE_PATH variable.

    More PHP Articles
    More By Ian Felton


       · I worked on a project that was implemented using a template, like this. The CPU...
     

       

    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 2 hosted by Hostway