ploneplone-5.x

Adding custom index for sorting of collections in Plone 5


In order to rank my plone pages by a number of positive ratings that the users have given them I am using the cioppino.twothumbs addon and now want to sort a collection by number of positive ratings.

I want to add a custom index from the Plone 5 addon cioppino.twothumbs as sortable index to Plone collections. The index is called positive_ratings and registered by catalog.xml of cioppino.twothumbs. In my custom branch of the addon I added the code mentioned in the documentation:

<records interface="plone.app.querystring.interfaces.IQueryField"
       prefix="plone.app.querystring.field.positive_ratings">
<value key="title">Positive Ratings</value>
<value key="description">total number of positive ratings</value>
<value key="enabled">False</value>
<value key="sortable">True</value>
<value key="operations">
</value>
<value key="group">Metadata</value>

to the registry.xml of the addon. Unfortunately I have this index not visible as sortable on the Add Collection page, although it is available as additional column of the Collection.

This Question is similar to this one, but unlike the user there I have not modified the plone.app.querystring source code, but my custom branch of cioppino.twothumbs, as suggested by the answer.


Solution

  • The code was completely correct, however I forgot to rerun the installation of the addon for the registry to get updated. This solved the problem completely and enabled the sorting of collections by this value.