PEAR Articles

  Home arrow PEAR Articles arrow Page 3 - The PEAR ITX Templating System
PEAR ARTICLES

The PEAR ITX Templating System
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    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

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap