Skip to content

Lovely snippet for inclusion: overriding a portlet #118

@jean

Description

@jean

Logging this here so it isn't forgotten.

On Thu, Oct 25, 2012 at 3:06 AM, Jens W. Klein jens@bluedynamics.com wrote:

On 2012-10-24 20:56, Tarlika Elisabeth Schmitz wrote:
I would like to display the items in the navigation portlet in reverse
chronological order.

Any advice how to achieve this would be greatly appreciated.

Best is to override navigation trees querybuilder.

The interface of this adapter is
plone.app.layout.navigation.interfaces.INavigationQueryBuilder

To achieve this just subclass default querybuilder, see
https://github.com/plone/plone.app.portlets/blob/master/plone/app/portlets/portlets/navigation.py#L294
and add the methods sortAttribute and sortOrder, ie.:.

from plone.app.portlets.portlets.navigation import QueryBuilder

class MyQuerybuilder(QueryBuilder):

    def sortAttribute(self):
       return 'created'

    def sortOrder(self):
       return 'reversed'

Then create and integrate (buildout -> zcml-overrides) an overrides.zcml
and register your adapter to replace the default one.

hth Jens
Klein & Partner KG, member of BlueDynamics Alliance

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions