Details
-
Type:
Feature Request
-
Status:
Contributed Solution
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 6.1.1 CE GA2, 6.1.20 EE GA2
-
Fix Version/s: None
-
Component/s: WCM, WCM > Asset Publisher
-
Labels:None
-
Liferay Contributor's Agreement:Accept
-
Similar Issues:
Description
Currently the Asset Publisher allows to show some metadata about the assets but some good are missing. My suggestion: add the asset description and the last author of an asset. To do so, follow these steps:
- Add these imports to this file https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/init.jsp
<%@ page import="com.liferay.portlet.documentlibrary.model.DLFileVersion" %> <%@ page import="com.liferay.portlet.documentlibrary.service.DLFileVersionLocalServiceUtil" %>
- Change this line https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/init.jsp#L215
String allMetadataFields = "create-date,modified-date,publish-date,expiration-date,priority,author,view-count,categories,tags,description,last-author";
- Change this line https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/css/main.css#L145
.metadata-author, .metadata-last-author { - Add this style here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/css/main.css#L173
.metadata-description { margin-right: 10px; } - Add these lines here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L177
else if (metadataFields[m].equals("description")) { value = HtmlUtil.escape(assetEntry.getDescription()); } else if (metadataFields[m].equals("last-author")) { if (assetEntry.getClassName().equals("com.liferay.portlet.documentlibrary.model.DLFileEntry")) { DLFileVersion fileVersion = DLFileVersionLocalServiceUtil.getLatestFileVersion(assetEntry.getClassPK(), true); value = HtmlUtil.escape(fileVersion.getStatusByUserName()); } else { String userName = PortalUtil.getUserName(assetRenderer.getUserId(), assetRenderer.getUserName()); value = HtmlUtil.escape(userName); } } - Add these lines here https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/asset_metadata.jspf#L64
else if (metadataFields[j].equals("description")) { value = HtmlUtil.escape(assetEntry.getDescription()); } else if (metadataFields[j].equals("last-author")) { if (assetEntry.getClassName().equals("com.liferay.portlet.documentlibrary.model.DLFileEntry")) { DLFileVersion fileVersion = DLFileVersionLocalServiceUtil.getLatestFileVersion(assetEntry.getClassPK(), true); value = LanguageUtil.get(pageContext, "by") + StringPool.SPACE + HtmlUtil.escape(fileVersion.getStatusByUserName()); } else { String userName = PortalUtil.getUserName(assetRenderer.getUserId(), assetRenderer.getUserName()); value = LanguageUtil.get(pageContext, "by") + StringPool.SPACE + HtmlUtil.escape(userName); } }
Furthermore there's a problem with author<>last author. The author for dlfiles is always the creator while on journals/web content the author is the last editor. To fix this, change these lines: https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/display/table.jsp#L144 and https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/portlet/asset_publisher/asset_metadata.jspf#L49
String userName = assetEntry.getUserName();
You will also need to add "last-author" to the language files.

In preparation for Ideation; we are moving this contributed solution tickets to “Feature Request”. Additional information to follow.