As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Hello,
What is the best solution to sort page provider result by number of downloads ?
Thanks.
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.
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.
Hi LaraGranite,
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 }}