PEAR Articles
  Home arrow PEAR Articles arrow Page 3 - The PEAR ITX Templating System
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
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? 
PEAR ARTICLES

The PEAR ITX Templating System
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2003-01-08

    Table of Contents:
  • The PEAR ITX Templating System
  • Searching for solutions
  • Adding ITX to your PHP script
  • How to make templates
  • The conclusion

  • 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


    The PEAR ITX Templating System - Adding ITX to your PHP script


    (Page 3 of 5 )

    First of all, ITX is a part of the PEAR project. While you do not need to have the complete set of PEAR files accompanying your script, you will most likely want to distribute the ITX source with your script. I've only worked with a scarce few web hosting companies that have PEAR classes preinstalled for their clients.

    ITX is object-oriented like all PEAR code. Don't worry though. Even if you can't get a grip on OOP, there are only a few tricks you need to learn to use it properly and effectively in your applications!

    What do you need?

    Assuming you have already configured your PHP and added PEAR's directory into your include path, it's a very simple process to put ITX into your application:

    <?php
    include("HTML/ITX.php");
    ?>

    Basics of the templating system

    To initialize the templating system, we need to make an instance of the IntegratedTemplateExtension class:

    <?php
    $tpl 
    = new IntegratedTemplateExtension("/template/location/");
    ?>

    From now on, every time we mention the $tpl variable, we are talking about this instance of the IntegratedTemplateExtension class.

    The ITX constructor takes one parameter. This parameter (with the value "/template/location/" in the example) is the directory from which templates will be loaded.

    In order to process data from a template, we need to instruct ITX to load that template. Here is how we do it:

    <?php
    $tpl
    -&gt;loadTemplatefile("school-grades.tpl");
    ?>

    This will load the file named school-grades.tpl into the instance of ITX, and will enable you to start processing your template. Beware, though, that this method does not report errors. No error will be reported, and no template will be loaded if you use a non-existent file name. Your script will just die in silence without an easy diagnostic method.

    More PEAR Articles Articles
    More By Codewalkers


       · For those interested in the integrated doc in the source code, you can find a phpDoc...
       · I've been struggling trying to get the phplib template system to work (with nested...
       · I've been using them for almost almost a year now. I was using PHPlib template.inc...
     

    PEAR ARTICLES ARTICLES

    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR
    - The PEAR Package Tour: PEAR Basics
    - Caching with PEAR::Cache
    - Introduction to PEAR
    - The PEAR ITX Templating System





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT