Zope
  Home arrow Zope arrow Page 5 - ZPT Basics (part 2)
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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? 
ZOPE

ZPT Basics (part 2)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2002-09-25

    Table of Contents:
  • ZPT Basics (part 2)
  • A Little Male Bonding
  • The Number Game
  • A Question Of Scope
  • Switching Things Around
  • Comparing Apples and Oranges
  • If It's Thursday, It Must be Italy
  • Submitting To The King
  • Looking Ahead

  • 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

    Save your reputation with your customers. Learn how you can have embedding success with Advantage Database Server (ADS).

    ZPT Basics (part 2) - Switching Things Around
    (Page 5 of 9 )

    Now that you know how variables work, it's time to examine the TAL"condition" attribute, which lets you add decision-making capabilitiesto your templates. In this section, I'll be examining conditionalexpressions and comparison operators, and demonstrating, with practicalexamples, how they can be used to craft more intelligent code.

    Let's begin with a simple example:
    <span tal:define="global switch string:on"></span><span tal:condition="switch">You left the light switch on</span>
    In this case, the visibility of the second <span> depends on thepresence or absence of the "switch" variable. If the variable ispresent, the second <span> will be displayed; if not, it will remainhidden.

    All this happens via the special TAL "condition" attribute, which,according to the TAL specification, is used to "...include a particularpart of a Template only under certain conditions, and omit itotherwise". This TAL attribute is thus analogous to the traditional "if"statement found in all programming languages, and it can come in veryhandy when you need to add control flow routines to your templates.

    The expression provided to the "condition" attribute must be a validTALES expression, which evaluates to either true or false.

    More Zope Articles
    More By Harish Kamath, (c) Melonfire


     

       

    ZOPE ARTICLES

    - Creating Zope Products
    - Plone Content Types With Archetypes
    - Flat User Management in Zope
    - Creating Basic Zope Applications
    - Getting started with Zope for Linux and Sola...
    - ZPT Basics (part 4)
    - ZPT Basics (part 3)
    - ZPT Basics (part 2)
    - ZPT Basics (part 1)
    - Exception Handling In DTML
    - DTML Basics (part 4)
    - DTML Basics (part 3)
    - DTML Basics (part 2)
    - DTML Basics (part 1)
    - Using Zope With Apache




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