I'm just starting to work with ZPT (as of today), the first question I have is; Is there a way to keep "template/title" from being displayed in the list that is generated by the tal:repeate directive? I'd like to generate a list of links that does not include the index_html page. My second question is: Is there any way to sort the list that's generated? --The code that I have-- <title tal:content="template/title">Title</title> </head> <body> <font size=+1 tal:content="template/title">Title</font> <UL tal:condition="container/objectValues"> <LI tal:repeat="item container/objectValues"> <span tal:replace="item/title">ITEM</span> </LI> </UL> thanks in advance
G. wrote on Wednesday, March 5, 2003, 10:38:58 PM:
I'd like to generate a list of links that does not include the index_html page.
Notice the tal:condition="python:item.getId()<>'index_html'" below. Also notice the general use of object/title_or_id instead of just object/title.
My second question is: Is there any way to sort the list that's generated?
Sort is a bit awkward inside page templates. The sort part of this code is basically ripped from the API reference in the Zope Book. It does an insensitive sort on the title, then date. <font size=+1 tal:content="template/title_or_id">Title</font> <UL tal:condition="container/objectValues" tal:define="objects here/objectValues; sort_on python:(('title', 'nocase', 'asc'), ('bobobase_modification_time', 'cmp', 'desc')); sorted_objects python:sequence.sort(objects, sort_on)"> <LI tal:repeat="item sorted_objects"> <span tal:define="i item/title_or_id" tal:condition="python:item.getId()<>'index_html'" tal:replace="i">ITEM</span> </LI> </UL> If you're wanting to do anything very complicated with lists, i'd just write a python script to generate the list the way you want it, then loop over that. -- Tim Middleton | Cain Gang Ltd | "Who is Ungit?" said he, still holding x@veX.net | www.Vex.Net | my hands. --C.S.Lewis (TWHF) 1
hrmm looks like my enthusiasm for ZPT has hit a lull. Thanks for the help, It's greatly appreciated. On Thursday 06 March 2003 01:47 am, you wrote:
G. wrote on Wednesday, March 5, 2003, 10:38:58 PM:
I'd like to generate a list of links that does not include the index_html page.
Notice the tal:condition="python:item.getId()<>'index_html'" below. Also notice the general use of object/title_or_id instead of just object/title.
My second question is: Is there any way to sort the list that's generated?
Sort is a bit awkward inside page templates. The sort part of this code is basically ripped from the API reference in the Zope Book. It does an insensitive sort on the title, then date.
<font size=+1 tal:content="template/title_or_id">Title</font> <UL tal:condition="container/objectValues" tal:define="objects here/objectValues; sort_on python:(('title', 'nocase', 'asc'), ('bobobase_modification_time', 'cmp', 'desc')); sorted_objects python:sequence.sort(objects, sort_on)"> <LI tal:repeat="item sorted_objects"> <span tal:define="i item/title_or_id" tal:condition="python:item.getId()<>'index_html'" tal:replace="i">ITEM</span> </LI> </UL>
If you're wanting to do anything very complicated with lists, i'd just write a python script to generate the list the way you want it, then loop over that.
Don't let that lull you. ZPTs help in the separation of logic (sorting the list) and data (the list) and presentation (showing the sorted list). If you want a sorted list the best way to do it is to create a python script to do the sorting of the list and return it.. This keeps the tal:define/tal:conditions down to a minimum. On Thu, 2003-03-06 at 07:47, G. Clifford Williams wrote:
hrmm looks like my enthusiasm for ZPT has hit a lull. Thanks for the help, It's greatly appreciated.
On Thursday 06 March 2003 01:47 am, you wrote:
G. wrote on Wednesday, March 5, 2003, 10:38:58 PM:
I'd like to generate a list of links that does not include the index_html page.
Notice the tal:condition="python:item.getId()<>'index_html'" below. Also notice the general use of object/title_or_id instead of just object/title.
My second question is: Is there any way to sort the list that's generated?
Sort is a bit awkward inside page templates. The sort part of this code is basically ripped from the API reference in the Zope Book. It does an insensitive sort on the title, then date.
<font size=+1 tal:content="template/title_or_id">Title</font> <UL tal:condition="container/objectValues" tal:define="objects here/objectValues; sort_on python:(('title', 'nocase', 'asc'), ('bobobase_modification_time', 'cmp', 'desc')); sorted_objects python:sequence.sort(objects, sort_on)"> <LI tal:repeat="item sorted_objects"> <span tal:define="i item/title_or_id" tal:condition="python:item.getId()<>'index_html'" tal:replace="i">ITEM</span> </LI> </UL>
If you're wanting to do anything very complicated with lists, i'd just write a python script to generate the list the way you want it, then loop over that.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev ) -- Edward Muller
Interlix - President Web Hosting - PC Service & Support Custom Programming - Network Service & Support Phone: 417-862-0573 Cell: 417-844-2435 Fax: 417-862-0572 http://www.interlix.com
<html> <head> <title tal:content="template/title">Title</title> </head> <body tal:define="objects container/objectValues;temp python:objects.sort(lambda x, y: cmp(x.title.upper(), y.title.upper()))"> <font size=+1 tal:content="template/title">Title</font> <ul tal:condition="objects"> <tal:block repeat="item objects"> <li tal:condition="python:item.id!=template.id"> <span tal:replace="item/title">ITEM</span> </li> </tal:block> </ul> </body> </html> You could also use item/title_or_id if you wanted to display the id if the object has no title... G. Clifford Williams wrote:
I'm just starting to work with ZPT (as of today), the first question I have is; Is there a way to keep "template/title" from being displayed in the list that is generated by the tal:repeate directive?
I'd like to generate a list of links that does not include the index_html page.
My second question is: Is there any way to sort the list that's generated?
--The code that I have--
<title tal:content="template/title">Title</title> </head> <body> <font size=+1 tal:content="template/title">Title</font> <UL tal:condition="container/objectValues"> <LI tal:repeat="item container/objectValues"> <span tal:replace="item/title">ITEM</span> </LI> </UL>
thanks in advance
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Where does one find a list of all of the attributes and properties that can be called/referenced from TAL statements? On Thursday 06 March 2003 08:22 pm, Chris Beaven wrote:
<html> <head> <title tal:content="template/title">Title</title> </head> <body tal:define="objects container/objectValues;temp python:objects.sort(lambda x, y: cmp(x.title.upper(), y.title.upper()))"> <font size=+1 tal:content="template/title">Title</font> <ul tal:condition="objects"> <tal:block repeat="item objects"> <li tal:condition="python:item.id!=template.id"> <span tal:replace="item/title">ITEM</span> </li> </tal:block> </ul> </body> </html>
You could also use item/title_or_id if you wanted to display the id if the object has no title...
G. Clifford Williams wrote:
I'm just starting to work with ZPT (as of today), the first question I have is; Is there a way to keep "template/title" from being displayed in the list that is generated by the tal:repeate directive?
I'd like to generate a list of links that does not include the index_html page.
My second question is: Is there any way to sort the list that's generated?
--The code that I have--
<title tal:content="template/title">Title</title> </head> <body> <font size=+1 tal:content="template/title">Title</font> <UL tal:condition="container/objectValues"> <LI tal:repeat="item container/objectValues"> <span tal:replace="item/title">ITEM</span> </LI> </UL>
thanks in advance
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
* G. Clifford Williams <gcw-python@rezidew.net> [2003-03-09 23:46:43 -0600]:
Where does one find a list of all of the attributes and properties that can be called/referenced from TAL statements?
Look at Appendix C in the Zope book, "Zope Page Template Reference". Find the Zope book here: http://www.zope.org/Documentation/Books/ZopeBook/current/ZopeBook.pdf thomas -- N. Thomas nthomas@cise.ufl.edu Etiamsi occiderit me, in ipso sperabo
G. Clifford Williams wrote at 2003-3-9 23:46 -0600:
Where does one find a list of all of the attributes and properties that can be called/referenced from TAL statements?
Someone else told you where to find information about build in functions. Zope is an object oriented system. Most objects provide methods which can be used in programs. You can find information about such methods by means of "DocFinder". See <http://www.dieter.handshake.de/pyprojects/zope> "DocFinderEveryWhere" might help you, too. Dieter
participants (6)
-
Chris Beaven -
Dieter Maurer -
Edward Muller -
G. Clifford Williams -
N. Thomas -
Tim