collective / collective/collective.developermanual

Lovely snippet for inclusion: overriding a portlet

Open
#118 0 comments 0 reactions 1 assignee Claimed by @pigeonflight View on GitHub
Dominant language
Python
Stars
81
Forks
104
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.