[CPS-users] How to sort items in sections, portlets, etc.?

Jean-Marc Orliaguet jmo at ita.chalmers.se
Wed Apr 12 16:08:58 CEST 2006


curios-one wrote:

>Thank you, now I'm starting to understand a little more about cps and cpsskins.
>The code you provided is very helpful. 
>I'm wondering if it's better to create new scripts and page templates to obtain what I need
>or modify the existing code.
>If I understood right what is in charge of showing folder contents in a base CPS installation
>is a navigation portlet (Folder contents) which calls the render method folder_contents_detailed.
>I found the code in portal_skins/cpsportlets_widgets/widget_portlet_navigation
>
>  <tal:block condition="python: display == 'folder_contents_detailed'">
>    <tal:block define="
>        cpsmcat nocall:here/translation_service;
>        base_url utool/getBaseUrl;
>        items python: context.getFolderContents();
>        format string:one_column;
>        no_form python:1;">
>      <metal:block use-macro="here/content_lib_
> display_contents/macros/display_contents" />
>    </tal:block>
>  </tal:block>
>
>Let me see if I understood well, getFolderContents get a list of the object in the folder and then the macro display_contents is in charge of building the html code
>  
>
> Is it possible to add a sort_by parameter to this code?
> Or add the sorting parameter, as you suggested,  in portal_layouts and 
> portal_schemas.
>
> I believe that adding sorting and direction parameters directly to the 
> section would be a nice improvement for cps... something like the 
> existing hidden_folder
> This could be a fast and simple way to have different sorting and 
> direction based on each section.
>
> Thank you
> C.



Hi, the best thing to do is to copy and paste code from 
widget_portlet_navigation (navigation portlet) as you've started doing, 
then remove all references to datastructures (ds options/datastructure 
and other parameters that come the portlet's own schema). Then create a 
custom portlet with the page template.

Since custom portlets have no parameters, all parameters available in 
the navigation portlet will have to be hardcoded in the page template 
instead. However the page template can also get information from the 
current section, which is what it does in the code I sent.

then pass the information to:

items python: context.getFolderContents(....);

I think it's called 'sort_on'

that should do the trick.

the schema / layout that you should modify is the one of the "Section" 
type (there is no need to change the portlet's schema / layout)

regards
/JM



More information about the cps-users mailing list
More information about CPS: CPS project - CVS - API

Hosting: Nuxeo: Zope service provider


This list archive provided by Nuxeo, the leaders of open source ECM. Check out the Nuxeo 5 open source, standards-based ECM project.