You are not logged in Log in Join
You are here: Home » Members » aho » Los Angeles Zope User Group » Los Angeles Zope User Group Meets August 18

Log in
Name

Password

 

Los Angeles Zope User Group Meets August 18

Zope Page Template and Plone Customization
When: Wednesday August 18, 2004 7-9pm

Where: Harbor-UCLA Medical Center, Torrance CA [Map + Directions]

Agenda 


7:00pm - 7:15pm : LAZug business meeting
7:15pm - 8:00pm : Special Presentation/Tutorial
   Zope Page Template Tutorial (Part I.) 
   We will be using the ZPT Chapter from the Zope Book as outline.
        

8:00pm - 9:00pm : special presentation / hands-on lab
   New Theme for LAZUG Plone/CMF site
Comment

Discussion icon DTML to ZPT Tutorial

Posted by: aho at 2004-08-18
Comment

Discussion icon quick summary

Posted by: aho at 2004-08-19

(written by Jeff, originally posted to http://www.lazug.org/lazugsite/laZugWiki/GeneralDiscussion )

We tackled the tutorial on ZPT, comparing many features to DTML. What we discovered was that ZPT is

  • Extremely XML like. We saw ways to incorporate the various TAL calls inside standard HTML tags, or to make XML namespace TAL objects to perform functions for us. We compared this a lot to the functionality of XSLT.

  • Often times more verbose than DTML. But at the same time, it was more precise than DTML.

  • The HTML output could be a lot cleaner when using ZPT. We noticed that there were instances where a lot of surrounding whitespace was shown in the output of DTML, but in ZPT it was not present. This was significant when providing output in a textarea element.

Andrew, Brian, and I stayed until about 11PM working through the tutorial, and it was a great path of discovery. Dallas had to catch his bus, but Brian was my captive. :) Andrew and I worked together trying to figure out the best way to work out a simple if-else scenario, and we discovered the way to do it was to have both examples of output, and use the tal:condition method, the condition relying on two mutually exclusive but always present properties.

The example was a drop down select form element, with one option in the drop down selected by default. My solution looks something like this:

<select name="xyz:list" tal:define="selected python:['e']; usernames python:[d,e,'f']; " > <tal:loop repeat="user python:usernames"> <option tal:condition="python:user in selected" tal:content="python:user" tal:attributes="value python:user" selected> $var </option> <option tal:condition="python:user not in selected" tal:content="python:user" tal:attributes="value python:user"> $var </option> </tal:loop> </select>

Notice first, I created the XML-NS like tal:loop tag. The word "loop" was completely arbitrary. Next, the option elements are identical except one has the "selected" boolean true. The condition is whether the current user in our loop is the one marked selected. That determines which of these two option elements to display. Finally, the $var is just a placeholder. I put the dollar mark there as a personal reminder that it won't be displayed. The content attribute will replace it. The attributes method will set attributes of the final option element, and you can set multiple, semicolon separated attributes with this method.

Overall, you may not follow this example if you weren't there, but maybe if you have looked at ZPT before, it might make sense.

I really learned a lot. I had very little understanding of ZPT previous to last night, but now I feel like I could actually accomplish a few things with it. I feel a lot more like we can tackle creating a new Plone skin for our site in the next few meetings. I think we agreed that was a goal we want to achieve, a skin for the site and then be able to extend it to the Wiki.