I am very new to Zope and Plone. I am trying to write python code in the index_html page. I have the list of objects of type person, now I want to reorder them. So, what I had before was:
<ul tal:define="persons python: context.portal_catalog(portal_type='Person');">
<tal:listing repeat="p persons">
Now I have this python code before the <tal:listing…
<?python
order=[0,2,1]
persons = [persons[i] for i in order]
?>
But somehow the order of the person remains the same. Also, I also don’t like this way of writing python code in the view. Is there any way I could use this code for changing the order of the list?
Zope pagetemplates do not support a
<? ?>syntax at all.However, you can loop over your python list in the
tal:repeatjust fine:I suspect however, that you want to let the portal_catalog do the sorting instead, using the
sort_onparameter (see the Plone KB article on the catalog):If you want to do anything more complex, use a browser view to do the list massaging for you.