PHP
  Home arrow PHP arrow Page 9 - Template-Based Web Development With pa...
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 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
SunQuest
 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: 5 stars5 stars5 stars5 stars5 stars / 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:
      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

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    Template-Based Web Development With patTemplate (part 2) - Running On Empty


    (Page 9 of 14 )

    patTemplate also allows you to cover for the unexpected by specifying two additional sub-templates, one which is displayed when the decision variable cannot be matched, and one to be displayed when the decision variable is empty. Here's an example of how this might work:


    <patTemplate:tmpl name="fortune" type="condition" conditionvar="DAY"> <html> <head> <basefont face="Arial"> </head> <body> And today's fortune is: <br> <patTemplate:sub condition="Mon"> Never make anything simple and efficient when a way can be found to make it complex and wonderful. </patTemplate:sub> <patTemplate:sub condition="Tue"> Life is a game of bridge -- and you've just been finessed. </patTemplate:sub> <patTemplate:sub condition="Wed"> What sane person could live in this world and not be crazy? </patTemplate:sub> <patTemplate:sub condition="Thu"> Don't get mad, get interest. </patTemplate:sub> <patTemplate:sub condition="Fri"> Just go with the flow control, roll with the crunches, and, when you get a prompt, type like hell. </patTemplate:sub> <patTemplate:sub condition="default"> Sorry, closed on the weekend. </patTemplate:sub> <patTemplate:sub condition="empty"> Sorry, cannot determine day of week. Did the world just end? </patTemplate:sub> </body> </html> </patTemplate:tmpl>
    In this case, the sub-template specified as "default" will appear on Saturdays and Sundays, while the sub-template specified as "empty" will appear if {DAY} is empty. Try it out and see for yourself.

    You can force patTemplate to look in the global namespace for the value of the decision variable in case it's not available locally, by adding the optional "useglobals" attribute to your template definition.

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


     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery

    SunQuest




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway