[CLOSED] How can I reference DLFile custom data in ADT?[CLOSED] How can I reference DLFile custom data in ADT?https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=819990732024-03-29T10:05:15Z2024-03-29T10:05:15ZRE: How can I reference custom data in ADT?ildar slhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1186730302020-03-06T07:40:59Z2020-03-06T07:40:59Z<#list entries as entry><br /> <#assign<br /> entry = entry<br /> assetRenderer = entry.getAssetRenderer()<br /> entryTitle = htmlUtil.escape(assetRenderer.getTitle(locale))<br /> viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, assetRenderer, entry, !stringUtil.equals(assetLinkBehavior, "showFullContent"))<br /> className = assetRenderer.getClassName()!"x"<br /> dlFileEntryId = assetRenderer.getClassPK()<br /> fileEntry = DLAppLocalServiceUtil.getFileEntry(dlFileEntryId)<br /> fileVersion = fileEntry.getLatestFileVersion()<br /> /><br /> <#if className == "com.liferay.document.library.kernel.model.DLFileEntry"><br /> ${fileEntry.getExpandoBridge().getAttribute("nametext")}<br/><br /> </#if><br /></#list>ildar sl2020-03-06T07:40:59ZRE: How can I reference custom data in ADT?Mirto Silvio Busicohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=823663702016-11-14T10:39:57Z2016-11-14T10:39:57Z<html><head></head><body>Another step ahead.<br><br>Now the problem is that entry.getExpandoBridge.getAttributeNames() returns an empty string<br><br>Here the code I used in the Asset Publisher ADT for a document type called "MIO" with two custom field: MIOUsage and MIONotes.<br><br>The code:<br><pre><code>&lt;#if entries?has_content&gt;
&lt;#list entries as entry&gt;
&lt;#assign assetRenderer = entry.getAssetRenderer() /&gt;
&lt;#assign entryTitle = htmlUtil.escape(assetRenderer.getTitle(locale)) /&gt;
TITLE: ${entryTitle} <br>
&lt;#assign className = assetRenderer.getClassName()!"x" /&gt;
CLASSNAME: ${className} <br>
&lt;#if className == "com.liferay.document.library.kernel.model.DLFileEntry"&gt;
&lt;#assign myyy = entry.getExpandoBridge() /&gt;
EXPANDOBRIDGE: ${myyy.toString()} <br>
&lt;#assign yyy = myyy.getAttributeNames() /&gt;
LIST ATTRIBUTES: ${yyy.toString() } <br>
&lt;#list yyy&gt;
&lt;#items as y&gt;
NAME ATTRIBUTE: ${y} <br>
<!--#items-->
&lt;#else&gt;
THERE ARE NO ATTRIBUTE NAMES <br>
<!--#list-->
&lt;#assign xxx = myyy.getAttribute(" MIOUsage",false) !"FIELD NOT FOUND" /&gt;
EXPANDOBRIDGE: MIOUsage-fieldname value = ${xxx} <br>
&lt;#assign xxxl = myyy.getAttribute(" Usage",false) !"FIELD NOT FOUND" /&gt;
EXPANDOBRIDGE: MIOUsage-label value = ${xxxl} <br>
&lt;#else&gt;
It is NOT a DLFileEntry
<!--#if-->
<hr>
<!--#list-->
<!--#if--></code></pre><br><br>The result for an enty with all fields filled:<br><pre><code>TITLE: a_few_oh_sht_situations_640_27.jpg
CLASSNAME: com.liferay.document.library.kernel.model.DLFileEntry
EXPANDOBRIDGE: com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl@aa725
LIST ATTRIBUTES: java.util.Collections$3@3a4ee3aa
THERE ARE NO ATTRIBUTE NAMES
EXPANDOBRIDGE: MIOUsage-fieldname value = FIELD NOT FOUND
EXPANDOBRIDGE: MIOUsage-label value = FIELD NOT FOUND </code></pre><br><br>I tried to get field names and it returns an empty list.<br>I tried to access the fields with getAttribute using the field name or the field label: nothing is returned<br><br>How can I use getExpandoBridge.getAttributeNames() to get the attibute names?</body></html>Mirto Silvio Busico2016-11-14T10:39:57ZRE: How can I reference custom data in ADT?Mirto Silvio Busicohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=821538602016-11-08T08:59:00Z2016-11-08T08:59:00Z<html><head></head><body>A little step ahead.<br>Trying to follow the instructions at http://platinumbed-liferay.blogspot.it/2014/12/application-display-template-documents.html (that is for LR 6)<br>and https://web.liferay.com/it/community/forums/-/message_boards/message/73391506?_19_threadView=flat (to enable serviceLocator)<br><br>I came up with this adt:<br><pre><code>&lt;#if entries?has_content&gt;
&lt;#list entries as entry&gt;
&lt;#assign curFileEntry = entry /&gt;
&lt;#assign assetRenderer = curFileEntry.getAssetRenderer() /&gt;
&lt;#assign className = assetRenderer.getClassName()!"x" /&gt;
&lt;#if className == "com.liferay.document.library.kernel.model.DLFileEntry"&gt;
&lt;#assign dlFileEntryService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")&gt;
${dlFileEntryService }<br>
&lt;#assign xx = curFileEntry.getFileEntryId() &gt;
&lt;#assign dlFileEntry = dlFileEntryService.getFileEntry(xx)&gt;
<!--#if-->
<!--#list-->
<!--#if--></code></pre><br><br>This gives the error<br><pre><code>The following has evaluated to null or missing:
==&gt; curFileEntry.getFileEntryId [in template "20116#20160#66884" at line 9, column 27]
</code></pre><br>on getFileEntryId <br><br>Any hint on how to convert the code in the blog to LR 7?</body></html>Mirto Silvio Busico2016-11-08T08:59:00ZRE: How can I reference custom data in ADT?Mirto Silvio Busicohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=821158712016-11-07T12:00:38Z2016-11-07T12:00:38Z<html><head></head><body>I've found an old article at http://platinumbed-liferay.blogspot.ch/2014/12/application-display-template-documents.html<br><br>I've put <br><pre><code>freemarker.engine.restricted.variables=
</code></pre><br>in portal.properties. Then tried this code:<br><br><pre><code>&lt;#if entries?has_content&gt;
&lt;#list entries as curEntry&gt;
${curEntry.getTitle(locale)}
&lt;#assign dlFileEntryService = serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService")&gt;
<hr>
<!--#list-->
<!--#if-->
</code></pre><br><br>But I receive the error that serviceLocator is not found<br><pre><code>
The following has evaluated to null or missing:
==&gt; serviceLocator [in template "20116#20160#66884" at line 5, column 31]
</code></pre><br><br>Anyone knows how to manage this error?</body></html>Mirto Silvio Busico2016-11-07T12:00:38ZRE: How can I reference custom data in ADT?Mirto Silvio Busicohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=821041922016-11-07T08:42:27Z2016-11-07T08:42:27Z<html><head></head><body>One step ahead.<br>Inserting this code in ADT<br><pre><code>
&lt;#assign className = assetRenderer.getClassName()!"x" /&gt;
&lt;#if className == "com.liferay.document.library.kernel.model.DLFileEntry"&gt;
&lt;#assign metaf = stringUtil.split(metadataFields) !"x" /&gt;
&lt;#list metaf as metaf1&gt;
${metaf1}
<!--#list-->
<!--#if-->
</code></pre><br><br>I can list the metadata thea are enabled in the Asset Publisher configuration<br><br>The document is a DLFile so I changed the thread title<br><br>Still I don't know how to reference the custom data.<br><br>Seems I have to use DLFileEntryLocalServiceUtil but I don't know how</body></html>Mirto Silvio Busico2016-11-07T08:42:27Z[CLOSED] How can I reference DLFile custom data in ADT?Mirto Silvio Busicohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=819990722016-11-03T12:25:09Z2016-11-03T12:25:09Z<html><head></head><body>The thread continues at<br>https://web.liferay.com/community/forums/-/message_boards/message/82458841<br><br><br>I have the problem that I am not able to reference document type custom metadata fields.<br><br>In Content -> Documents and Media I have defined a new document type (eg MIO) with two metadata fields (eg MIOUsage and MIONotes).<br><br>In an asset publisher that displays only MIO document type I was able to define an ADT that displays Name, description and small image; but Iwas not able to reference the two custom fields.<br><br>I tried<br><pre><code>${assetRenderer.getMiousage()!"xxx"}</c