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  
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

PHP Fast Template
By: Ian Felton
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 18
    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:
      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


    PHP Fast Template
    ( Page 1 of 6 )

    Why separate presentation from logic? The simple answer to the question 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.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
     

       

    PHP ARTICLES

    - 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 ...
    - Method Chaining in PHP 5





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