Reversing folder order to have newer items on top
As Martin Aspeli stated out by comment on this:
BE WARNED: Doing this the way stated below will change the standard behaviour of all folders within the site and may break addon products
Look for an alternative way further down, if you only want this behaviour for special folders only
To change the order of folder contents, you only need to do 2 simple steps:
- reverse the sort order of the script that fetches the folder contents
- reverse the functionality of the "up" and "down" arrows
To reverse the sort order of the folder content itself, you only need to add a
contentFilter['sort_order'] = 'reverse'
to getFolderContents.py (you find the Original in CMFPlone/skins/plone_scripts) so that it contains these lines:
if not contentFilter.get('sort_on', None):
contentFilter['sort_on'] = 'getObjPositionInParent'
contentFilter['sort_order'] = 'reverse'
It's up to you if you make a copy to one of your own products (where it can brake in further Plone versions), "customize" it in the ZMI (where even changes on your Products will be overridden) or edit it in place (where it is overridden on Plone updates).
To reverse the functionality of the "up" and "down" arrows, you need to edit folder_contents.pt so that it reads<a href=""
title="Move item up"
i18n:attributes="title title_move_item_up;"
tal:attributes="href string:$here_url/folder_position?position=down&id=$quoted_item_id&template_id=${template_id}">
<img tal:replace="structure arrowUp" />
</a>
<a href=""
title="Move item down"
i18n:attributes="title title_move_item_down;"
tal:attributes="href string:$here_url/folder_position?position=up&id=$quoted_item_id&template_id=${template_id}">
<img tal:replace="structure arrowDown" />
</a>
(The important thing is the position=down and position=up)
This seems not to interfere with the drag'n'drop re-ordering (hurra!)Alternative way for individual folders only
(also usable as standard view of course, but only usable in Plone 2.1 and up)As an alternative, make a copy of the standard folder listing template (or whatever kind of folder view you want to reverse) and use for example:
here.getFolderContents(contentFilter = {'sort_on' : 'Date', 'sort_order' : 'reverse' })
orhere.getFolderContents(contentFilter = {'sort_on' : 'getObjPositionInParent', 'sort_order' : 'reverse' })
instead of the standard here.getFolderContents()
The rest of the customization is like the one mentioned above for the template, no need to customize the getFolderContents script for that. The last step would be to register the new template as view for folders (you could simply add it to the list of templates under portal_types/Folder in the ZMI or seek further documentation on how to add a view to your own or the standard folder type)
By the way: this does not even interfere with the changes above, as they only fire without any contentFilter set. The first alternative only reverses the standard behaviour if no other behaviour was given by the calling template. Which can be good and bad: It should make interferences with other products or expected behaviour less a problem, but it also means that whenever you change the sort filter, you will need to reverse on your own. This could also be very confusing to people that are allowed to create new searches like smart folders or have access to the ZMI and do not know about the "natural" order Zope uses. (remember that the "real order" will remain the same as before with newer items on the bottom (if I find out who is responsible for that on a web project...))

Author: