06-12-2019 04:37 AM
Hello,
What is the best solution to sort page provider result by number of downloads ?
Thanks.
06-20-2019 12:05 PM
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.
06-21-2019 03:11 AM
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?
07-09-2019 07:08 PM
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.
07-10-2019 03:48 AM
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 }}
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.