Forums de discussion

How can i show user upload in Document Library ?

thumbnail
Alex Nguyen, modifié il y a 14 années.

How can i show user upload in Document Library ?

Junior Member Publications: 60 Date d'inscription: 17/09/08 Publications récentes
im using Document Library to store some document and i have some user can upload data but now i want know when he or she upload the data, the information of file will be:


name size download datetime user

can you help me ?

thanks so much.

Alex
Mazhar Anwar, modifié il y a 14 années.

RE: How can i show user upload in Document Library ?

Regular Member Publications: 125 Date d'inscription: 05/02/10 Publications récentes
Alex Nguyen:
im using Document Library to store some document and i have some user can upload data but now i want know when he or she upload the data, the information of file will be:


name size download datetime user

can you help me ?

thanks so much.

Alex
Hi Alex,

Documents entries are added to DLFileEntry table in Liferay, where you can find all related information for documents,

You can get more documents related information in TagsAsset table, since for each document upload, Liferay adds entries in tagsAssets table and maintain the counter for each asset downloads.

you can fetch the data from any of the above tables by using any custom-sql or using any existing Liferay API(As per requirement) in your portlet.

HTH,
Mazhar
thumbnail
Erik Andersson, modifié il y a 14 années.

RE: How can i show user upload in Document Library ?

Junior Member Publications: 39 Date d'inscription: 08/04/08 Publications récentes
Hi Alex,

I would use a model listener to tap into the event that a new document library entry has been made:

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Portal+Hook+Plugins

Cheers,
Erik
thumbnail
Alex Nguyen, modifié il y a 14 années.

RE: How can i show user upload in Document Library ?

Junior Member Publications: 60 Date d'inscription: 17/09/08 Publications récentes
Thank for your reply but

Im not still clearly.

Can you tell me the way to do it.

thanks.
thumbnail
Erik Andersson, modifié il y a 14 années.

RE: How can i show user upload in Document Library ?

Junior Member Publications: 39 Date d'inscription: 08/04/08 Publications récentes
You implement a model listener with a hook. Hooks and model listeners are described in the wiki post I linked to. Also, take a look at the SevenCogs hook that comes with your Liferay bundle to get a more handson grip on how hooks are used.

One thing has changed since Ray wrote the wiki post:
Now you don't register your model listener in the liferay-hook.xml file. You rather specify your model listener in a portal.properties file, and then register the portal.properties file in the liferay-hook.xml file.

1. To register a model listener - create a portal.properties file in your hook and specify your listener:
value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry=my.package.hook.listeners.DLFileEntryListener


2. Add your portal.properties to your liferay-hook.xml file:

<hook>
	<portal-properties>portal.properties</portal-properties>
</hook>


3. Add your new listener class to your hook:

package my.package.hook.listeners;
import com.liferay.portal.ModelListenerException;
import com.liferay.portal.model.BaseModelListener;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;

public class DLFileEntryListener extends BaseModelListener<group> {

	public void onAfterCreate(DLFileEntry entry) throws ModelListenerException {
	
		// The code you wish to be executed when a new entry has been made
	
		System.out.println("A new document library entry was created");
	
	}

}</group>


Hooks can be tricky to get at first. But play around with them for a while. Learning how they work unveils a lot of possibilities in Liferay.

Cheers,
Erik