PHP
  Home arrow PHP arrow Page 6 - Template-Based Web Development With patTemplate (part 2)
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? 
PHP

Template-Based Web Development With patTemplate (part 2)
By: Team Melonfire, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 10
    2002-06-19


    Table of Contents:
  • Template-Based Web Development With patTemplate (part 2)
  • Scoping It Down
  • Speaking In Tongues
  • Looping The Loop
  • Legal Eagles
  • Hide And Seek
  • Setting Things Right
  • Fortune Favours The Brave
  • Running On Empty
  • Simple Simon
  • Brain Dump
  • A Well-Formed Example
  • Crash Bang Boom
  • Endgame

  • 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


    Template-Based Web Development With patTemplate (part 2) - Hide And Seek
    ( Page 6 of 14 )

    You can alter the visibility of a particular template via its "visibility" attribute. Consider the following example:


    <patTemplate:tmpl name="main"> I spy, with my little eye... <br> <patTemplate:link src="toaster" /> </patTemplate:tmpl> <patTemplate:tmpl name="toaster" visibility="hidden"> ...a template beginning with T </patTemplate:tmpl>
    Here's the script:

    <?php // include the class include("include/patTemplate.php"); // initialize an object of the class $template = new patTemplate(); // set template location $template->setBasedir("templates"); // add templates to the template engine $template->readTemplatesFromFile("toaster.tmpl"); // parse and display the template $template->displayParsedTemplate("main"); ?>
    And here's the output:

    I spy, with my little eye...
    Since the "visibility" attribute of the second template is set to "hidden", it will never be displayed by the template engine. In order to display it, you'll need to turn visibility to "visible" (or just remove the "visibility" attribute altogether):

    <?php // include the class include("include/patTemplate.php"); // initialize an object of the class $template = new patTemplate(); // set template location $template->setBasedir("templates"); // add templates to the template engine $template->readTemplatesFromFile("toaster.tmpl"); // turn visibility on for "toaster" template // comment out the next line to have the template vanish $template->setAttribute("toaster", "visibility", "show"); // parse and display the template $template->displayParsedTemplate("main"); ?>
    And now the output will include that missing section:

    I spy, with my little eye... ...a template beginning with T
    As you will see, though this might not seem like a big deal right now, it becomes extremely powerful when combined with the ability to programmatically alter the "visibility" attribute on the fly. That's discussed on the next page.

     
     
    >>> More PHP Articles          >>> More By Team Melonfire, (c) Melonfire
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





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