I am using this code to generate a navigation bar. I need to have a different bgcolor attribute on the td if we're already in that folder. In other words, I need to do tal:attributes="bgcolor string:red" but only where folder == here. The condition only applies to the bgcolor attribute so I'm not sure where it goes. Any ideas? <table> <tr tal:define="subfolders python:container.objectValues('Folder')"> <td tal:repeat="folder subfolders" bgcolor="yellow"> <span tal:replace="folder/title">Title</span> </td> </tr> </table>
Maybe something like: <table> <tr tal:define="subfolders python:container.objectValues('Folder')"> <span tal:repeat="folder subfolders" tal:omit-tag=""> <td tal:attributes="bgcolor python:('yellow','red')[here is folder]" tal:content="folder/title> Title </td> </span> </tr> </table> It relies on the fact the "here is folder" always returns either a 1 or a 0 hth, Casey On Monday 29 April 2002 03:13 pm, Tom Nixon allegedly wrote:
I am using this code to generate a navigation bar. I need to have a different bgcolor attribute on the td if we're already in that folder. In other words, I need to do tal:attributes="bgcolor string:red" but only where folder == here. The condition only applies to the bgcolor attribute so I'm not sure where it goes. Any ideas?
<table> <tr tal:define="subfolders python:container.objectValues('Folder')"> <td tal:repeat="folder subfolders" bgcolor="yellow"> <span tal:replace="folder/title">Title</span> </td> </tr> </table>
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Casey Duncan writes:
<table> <tr tal:define="subfolders python:container.objectValues('Folder')"> <span tal:repeat="folder subfolders" tal:omit-tag=""> <td tal:attributes="bgcolor python:('yellow','red')[here is folder]" tal:content="folder/title> Title </td> </span> </tr> </table>
It relies on the fact the "here is folder" always returns either a 1 or a 0 Be very careful when comparing acquisition wrapped objects.
They may compare unequal while you think they were the same object. This will happen because almost any access in Zope creates a new acquisition wrapper around the object. Dieter
Chris Withers writes:
Dieter Maurer wrote:
They may compare unequal while you think they were the same object. This will happen because almost any access in Zope creates a new acquisition wrapper around the object.
I'm pretty sure Jim has fixed this now... He might have fixed it for "==" (which would be right).
I would be extremely surprised if he had fixed it for "is" (which would be wrong and probably mean a change in the Python interpreter). Dieter
Tom Nixon writes:
... I need to have a different bgcolor attribute on the td if we're already in that folder. Assuming, ids are unique, you can use:
tal:attributes=" bgcolor python: here.getId() == folder.getId() and 'other bgcolor' or default; " Dieter
On Mon, Apr 29, 2002 at 08:13:15PM +0100, Tom Nixon wrote:
I am using this code to generate a navigation bar. I need to have a different bgcolor attribute on the td if we're already in that folder. In other words, I need to do tal:attributes="bgcolor string:red" but only where folder == here. The condition only applies to the bgcolor attribute so I'm not sure where it goes. Any ideas?
See my sitemap layout at www.zope.org/Members/mwr/python_zpt_sitemap (Google cache at http://216.239.51.100/search?q=cache:www.zope.org/Members/mwr/python_zpt_sit... -- assuming that my recent problem getting through to zope.org isn't just local to here) for a similar problem and solution. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
participants (5)
-
Casey Duncan -
Chris Withers -
Dieter Maurer -
Mike Renfro -
Tom Nixon