掲示板

Portal 6.0.6 - Asset Publisher Question

thumbnail
11年前 に Joseph Wolfe によって更新されました。

Portal 6.0.6 - Asset Publisher Question

Regular Member 投稿: 103 参加年月日: 11/02/22 最新の投稿
I am in need of using the "Link Title" option in the Asset Publisher portlet in a way that will allow a document to be directly opened when clicking the link as opposed to opening the document detail page which contains the direct link to the document.

For example the links would appear as this:

this is link1
this is link 2
this is link 3

and when any of these are clicked the document opens.

I am thinking that this should be simple. However, for what I am doing it is mandatory that I use the "Link Title" option and not the "Full Content" option when setting it up.

Does that make sense?
thumbnail
11年前 に Joaquin Cabal によって更新されました。

RE: Portal 6.0.6 - Asset Publisher Question

Regular Member 投稿: 106 参加年月日: 09/09/07 最新の投稿
Hi Joseph,
As I saw in this Issue: http://issues.liferay.com/browse/LPS-31818, that is happening un Liferay 6.1, open directly a document in the Asset Publicher title, is not available.
Is a future.
I test it in Liferay 6.06 and the same is happeniing, you jave to pass by another plus step, to download the document.

Fortunately is an option to fix it, in this Issue is the solution:

If you need it now you can hook the Asset Publisher. Create a new hook in your Liferay IDE and build up this path: docroot/META-INF/custom_jsps/html/portlet/asset_publisher/display/
Now copy the file "table.jsp" (it's exactly the same for "abstracts.jsp" and "title-list.jsp", I'll just do the example with "table.jsp") from your ROOT/html/portlet/asset_publisher/display/ folder into it. You will have to do some additions in this file:

Here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L16 you have to add this:

<%@ page import="com.liferay.portlet.documentlibrary.model.DLFileEntry" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil" %>

And here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L65 add this:

try {
DLFileEntry fileEntry = DLFileEntryServiceUtil.getFileEntry(assetEntry.getClassPK());
if (!fileEntry.getExtension().equals("pdf")) {
viewURL = themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" + fileEntry.getGroupId() + "/" + fileEntry.getFolderId() + "/" + HttpUtil.encodeURL(HtmlUtil.unescape(fileEntry.getTitle())) + "?version=" + fileEntry.getVersion();
}
} catch (Exception e) {
//
}

Regards!
thumbnail
11年前 に Joseph Wolfe によって更新されました。

RE: Portal 6.0.6 - Asset Publisher Question

Regular Member 投稿: 103 参加年月日: 11/02/22 最新の投稿
Hello-

I have tried implementing the code in 6.0.6. After implementation the portlet returns no data. Did I miss something?
Thanks
Joe

Line 16
<%@ page import="com.liferay.portlet.documentlibrary.model.DLFileEntry" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil" %>

Line 65
try {
DLFileEntry fileEntry = DLFileEntryServiceUtil.getFileEntry(assetEntry.getClassPK());
if (!fileEntry.getExtension().equals("pdf")) {
viewURL = themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" + fileEntry.getGroupId() + "/" + fileEntry.getFolderId() + "/" + HttpUtil.encodeURL(HtmlUtil.unescape(fileEntry.getTitle())) + "?version=" + fileEntry.getVersion();
}
} catch (Exception e) {
//
}
thumbnail
11年前 に Joaquin Cabal によって更新されました。

RE: Portal 6.0.6 - Asset Publisher Question

Regular Member 投稿: 106 参加年月日: 09/09/07 最新の投稿
Hi, there are some changes between 6.06 and 6.1 versions, so the workaraund should change to the following:

The file you need to change in hook is:
/html/portlet/asset_publisher/display/title_list.jsp

Import there these classes:

<%@ page import="com.liferay.portlet.documentlibrary.model.DLFileEntry" %>
<%@ page import="com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil" %>


and change the next code:

Where you have this:
<li class="title-list <%= assetRendererFactory.getType() %>">
<liferay-ui:icon
label="<%= true %>"
message="<%= HtmlUtil.escape(title) %>"
src="<%= assetRendererFactory.getIconPath(renderRequest) %>"
url="<%= viewURL.toString() %>"
/>

<liferay-util:include page="/html/portlet/asset_publisher/asset_actions.jsp" />

<div class="asset-metadata">
<%@ include file="/html/portlet/asset_publisher/asset_metadata.jspf" %>
</div>
</li>


you can put this code:

<c:if test='<%=assetRendererFactory.getType().equals("document")%>'>
<%
DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(assetEntry.getClassPK());
viewURL = themeDisplay.getPortalURL() + themeDisplay.getPathContext() + "/documents/" +
fileEntry.getGroupId() + "/" + fileEntry.getFolderId() + "/" +
HttpUtil.encodeURL(HtmlUtil.unescape(fileEntry.getTitle())) + "?version=" + fileEntry.getVersion();
%>

<li class="title-list <%= assetRendererFactory.getType() %>">
<liferay-ui:icon
label="<%= true %>"
message="<%= HtmlUtil.escape(title) %>"
src="<%= assetRendererFactory.getIconPath(renderRequest) %>"
url="<%= viewURL.toString() %>"
/>

<liferay-util:include page="/html/portlet/asset_publisher/asset_actions.jsp" />

<div class="asset-metadata">
<%@ include file="/html/portlet/asset_publisher/asset_metadata.jspf" %>
</div>
</li>

</c:if>
<c:if test='<%=!assetRendererFactory.getType().equals("document")%>'>
<li class="title-list <%= assetRendererFactory.getType() %>">
<liferay-ui:icon
label="<%= true %>"
message="<%= HtmlUtil.escape(title) %>"
src="<%= assetRendererFactory.getIconPath(renderRequest) %>"
url="<%= viewURL.toString() %>"
/>

<liferay-util:include page="/html/portlet/asset_publisher/asset_actions.jsp" />

<div class="asset-metadata">
<%@ include file="/html/portlet/asset_publisher/asset_metadata.jspf" %>
</div>
</li>

</c:if>

Regards
thumbnail
11年前 に Joseph Wolfe によって更新されました。

RE: Portal 6.0.6 - Asset Publisher Question

Regular Member 投稿: 103 参加年月日: 11/02/22 最新の投稿
Joaquin-

This worked perfectly, thank you for the assistance.Any idea as to how to edit this to provide the same functionality for images and bookmarks?

This should have been how it functioned out of the box. End users expect to click a link and have the action take effect - not be directed to another page containing the actual link.

Thanks again for your help.

Joe
thumbnail
10年前 に Joseph Wolfe によって更新されました。

RE: Portal 6.0.6 - Asset Publisher Question

Regular Member 投稿: 103 参加年月日: 11/02/22 最新の投稿
Joseph Wolfe:
Joaquin-

This worked perfectly, thank you for the assistance.Any idea as to how to edit this to provide the same functionality for images and bookmarks?

This should have been how it functioned out of the box. End users expect to click a link and have the action take effect - not be directed to another page containing the actual link.

Thanks again for your help.

Joe


I believe I have answered my own question here. Using the above code that Joaquin provided and setting the DISPLAY STYLE to "Title List" and ASSET LINK BEHAVIOR to "View in a specific portlet" the desired results can be achieved.

Resulting in the following scenerio where each of these links would open directly.

Document Link 1
Document Link 2
Website Link (URL)

If the DISPLAY STYLE is set to "Full Content" then only the 2 Document Links will open directly, but the Web Link will open to the intermediate page within the portlet.

Hope this helps.