Fórum

View document from Asset Publisher in Document library

thumbnail
M. Garcia, modificado 12 Anos atrás.

View document from Asset Publisher in Document library

Regular Member Postagens: 107 Data de Entrada: 17/05/11 Postagens Recentes
Hello,

I'm trying to change behaviour for viewFullContentURL in an AssetPublisher display mode, say MyDisplay.
My Asset Publisher is on Home page.

I would like this link to redirect to the document library portlet on another page, Documents page.

I need to get from the AssetEntry :
  • the file ID
  • the folder ID


With this I should be able to modify the struts_action parameter of the link with "document_library/view/<folderID>/<fileID>.

I managed to do this with Web Content, ie viewing full content of the Article in another Asset Publisher in another page.

But with the document library you need the folderID and the fileID, which I can't see a way to retrieve from the AssetEntry.

Any idea ?

Thanks a lot !
thumbnail
Hitesh Methani, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library (Resposta)

Regular Member Postagens: 171 Data de Entrada: 24/06/10 Postagens Recentes
Hi Garcia,

From AssetEntry object you can get ClassPk and that classPK will be dlFileEntryId,
Using that id you can get a DLFileEntry object which will help you to get the folderId for that document.

So you will have folderId and fileEntryId in hand, and for creating url for downloading the document itself
you can refer my blog http://hiteshmethani.blogspot.com/2011/06/creation-of-urls-for-entities-in.html.

Thanks,
Hitesh Methani.
thumbnail
M. Garcia, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library

Regular Member Postagens: 107 Data de Entrada: 17/05/11 Postagens Recentes
Hello Hitesh,

Thanks for your enlightment.

From AssetEntry object you can get ClassPk and that classPK will be dlFileEntryId,
Using that id you can get a DLFileEntry object which will help you to get the folderId for that document.


So this is DLFileEntryLocalServiceUtil.getFileEntry(pk).

I'm trying out, I'll let you know when I'm done (or stuck !). Thanks
thumbnail
M. Garcia, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library

Regular Member Postagens: 107 Data de Entrada: 17/05/11 Postagens Recentes
Well,

I managed to get the DLFileEntry.
But I'm in trouble to make up the link to the document view in Document Library :

...
long docPK = assetEntry.getClassPK();
DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.getFileEntry(docPK);

%&gt;
<liferay-portlet:renderurl var="viewFullContentURL" plid="10466">
	<liferay-portlet:param name="struts_action" value="/document_library/view_file_entry"></liferay-portlet:param>
	<liferay-portlet:param name="fileEntryId" value="<%= String.valueOf(dlFileEntry.getFileEntryId()) %>"></liferay-portlet:param>
</liferay-portlet:renderurl>
&lt;%
...


So far, this moves the user on the "Documents" page (plid=10466) but shows document library at its root folder.
I want to see the document description page.

I tried also with struts_action "/document_library/view" but with same results.

Deploring the lack of Liferay's API documentation, I'm not sure which struts action I should use and how to build the URL, so I'm counting on your help !

Thanks =)
thumbnail
Hitesh Methani, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library (Resposta)

Regular Member Postagens: 171 Data de Entrada: 24/06/10 Postagens Recentes
Hi Garcia,

Your struts action is correct but think you should also mention portlet name as the parameter.
Following is the required render url that you will need to create the link to the required document


<liferay-portlet:renderurl var="viewFullContentURL" plid="<%= 10466 %>" portletname="<%= PortletKeys.DOCUMENT_LIBRARY %>">
    <liferay-portlet:param name="struts_action" value="/document_library/view_file_entry"></liferay-portlet:param>
    <liferay-portlet:param name="folderId" value="<%= String.valueOf(fileEntry.getFolderId()) %>"></liferay-portlet:param>
    <liferay-portlet:param name="name" value="<%= HtmlUtil.unescape(fileEntry.getName()) %>"></liferay-portlet:param>
</liferay-portlet:renderurl>


The parameters needed are folderId and name of the file entry.

This url will open up document description page.

Hope this will help you.. emoticon

Regards,
Hitesh,
Cignex Technologies.
thumbnail
M. Garcia, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library

Regular Member Postagens: 107 Data de Entrada: 17/05/11 Postagens Recentes
Thanks a lot Hitesh !

It's up and running =)

Last thing, what is the way to set the "back to ..." link which is showed in the doc library ?
For example if I want this back link to return the user to the page he was before he wanted to see the document in the doc library.

Thanks !
thumbnail
Hitesh Methani, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library (Resposta)

Regular Member Postagens: 171 Data de Entrada: 24/06/10 Postagens Recentes
Hi Garcia,

The code in view_file_entry.jsp of document library says, the back link will always redirect to view parent folder of the file,
so if you want back button to behave differently, you will have to write a hook for document library, that will set the back url to previous url instead by reading the parameter value that you will set to current url while redirecting.

All you have to do is set an extra parameter while rendering the view document, read the value of that parameter in view_file_entry.jsp of document library hook and set the back url accordingly.

Hope this will help you out.

Regards,
Hitesh.
Cignex Technologies
thumbnail
M. Garcia, modificado 12 Anos atrás.

RE: View document from Asset Publisher in Document library

Regular Member Postagens: 107 Data de Entrada: 17/05/11 Postagens Recentes
Hey Hitesh,

Thanks a lot for the detailed explanation. =)
thumbnail
Enrique Valdes Lacasa, modificado 9 Anos atrás.

RE: View document from Asset Publisher in Document library

Junior Member Postagens: 92 Data de Entrada: 29/07/14 Postagens Recentes
From AssetEntry object you can get ClassPk and that classPK will be dlFileEntryId,
Using that id you can get a DLFileEntry object which will help you to get the folderId for that document.

Excellent contribution my friend. This inspired me to reach something I needed in Liferay 6.2: display the url of a document in the document library in my Asset Publisher via an ADT using Velocity. In the process of trying to find a solution for my need I found out something cool that maybe reading this could use.

To display a document via a Document Library view using Velocity (in an ADT for example), the following can be used:

#set($viewURL = $assetPublisherHelper.getAssetViewURL($renderRequest, $renderResponse, $entry))
#set($viewAsset = $renderer.getURLViewInContext($renderRequest, $renderResponse, $viewURL))
<a href="$viewAsset"> View file $entry.getTitle() in Document Library </a><a></a>

Being $entry the specific iteration of your document library file in the list of assets displayed through the ADT template ($entries).
shima shima, modificado 9 Anos atrás.

RE: View document from Asset Publisher in Document library

Junior Member Postagens: 46 Data de Entrada: 14/04/14 Postagens Recentes
hi Enrique
I have used your codes but it dose not work would you give me more guide