cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort page provider result by number of downloads ?

Yvan_Frezefond
Champ on-the-rise
Champ on-the-rise

Hello,

What is the best solution to sort page provider result by number of downloads ?

Thanks.

4 REPLIES 4

Rodri_
Star Contributor
Star Contributor

You can sort the list of results based on a field. That mean, you can order only based on information you have stored. The number of downloads of a document is not stored by default, you will need to store that value in a custom field for example, and then sort results based on that field.

One way of doing it is by creating a listener that increases the value of the custom field every time someone downloads a file.

Yvan_Frezefond
Champ on-the-rise
Champ on-the-rise

Hello,

Thanks for your answer.

That's what I was thinking to do with an event listener but I can not find event listener for download event.

Do you have any advice to create a listener on the download event?

Hi Yvan, if you haven't found a solution for this, my advice is to try to track the downloads by restricting them to a custom user action, so that users can only download by clicking this particular custom download button. Then you can attach a counter to that custom user action.

Yvan_Frezefond
Champ on-the-rise
Champ on-the-rise

Hi LaraGranite,

Thanks for your answer.

I was thinking to to that but I think that the the easiest way to do it is with a listener as said by Rodri.

Here is how I do that :

download-listener-contrib.xml :

<component name="fr.mycompany.listener" version="1.0">    <extension target="org.nuxeo.ecm.core.event.EventServiceComponent" point="listener">        <listener name="downloadListener" async="true" postCommit="true"                  class="fr.mycompany.listener.DownloadListener">            <event>download</event>        </listener>    </extension></component>

DownloadListener.java :

package fr.mycompany.listener;import org.nuxeo.ecm.core.event.Event;import org.nuxeo.ecm.core.event.EventContext;import org.nuxeo.ecm.core.event.EventListener;public class DownloadListener implements EventListener {    @Override    public void handleEvent(Event event) {        // Incrementing download count property    }}
Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.