Get value of select field in Application Display TemplateGet value of select field in Application Display Templatehttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1185491992024-03-29T06:15:11Z2024-03-29T06:15:11ZRE: Get value of select field in Application Display TemplateEric Dhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1185531672020-02-20T07:28:06Z2020-02-20T07:28:06ZHi,<br />As Mohammed writes, you can access from ADT the attributes of the structure but it is not the right way.<br />It will be nice to include your web content model in your ADT. <br /><br />The web content model can natively read the web content structure.<br /><br />Of course, sometimes ADT must access to an attribute of a content to make a filter or an order but the asset publisher can do this and do it better.<br /> <br />Like making a Liferay Ext, you should always thinking if it is the right way to do this.<br /><br />See the complete explanation in this blog :<br /><a href="https://liferay.dev/blogs/-/blogs/divide-and-conquer-rendering-structured-web-content-with-the-asset-publisher">https://liferay.dev/blogs/-/blogs/divide-and-conquer-rendering-structured-web-content-with-the-asset-publisher</a>Eric D2020-02-20T07:28:06ZRE: Get value of select field in Application Display TemplateMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1185528102020-02-20T07:09:21Z2020-02-20T07:09:21Z<html><head></head><body>Hi ,<br> For fetching field value from select you can use below code snippet, you can also use below code for fetching other value s <br><pre><code>
&lt;#if entries?has_content&gt;
&nbsp; &nbsp; &lt;#list entries as curEntry&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;#assign renderer = curEntry.getAssetRenderer()&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;#assign className = renderer.getClassName()&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;#if className == "com.liferay.journal.model.JournalArticle"&gt;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;#assign fields = &nbsp;renderer.getDDMFormValuesReader().getDDMFormValues().getDDMFormFieldValues() /&gt;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;#list fields as field&gt;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;#if field.getName() == "selectName"&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;#assign selectValue = jsonFactoryUtil.createJSONArray(field.getValue().getString(locale)).getString(0) /&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;${selectValue}
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<!--#if-->
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;#if field.getName() == "textName"&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;#assign textValue = field.getValue().getString(locale) /&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;${textValue}
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<!--#if-->
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<!--#list-->&nbsp;
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<!--#if-->
&nbsp;&nbsp; &nbsp;<!--#list-->&nbsp;
<!--#if-->
</code></pre></body></html>Mohammed Yasin2020-02-20T07:09:21ZGet value of select field in Application Display TemplateRajasree Nhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1185491982020-02-19T12:55:01Z2020-02-19T12:55:01ZHi Everyone,I am working with Liferay -7.0. I have a Select Field in my structure, where I can select multiple options. I am trying to get the values of the field in Application Display Template (ADT). I am able to get the values of other text fields using saxReader but not able to get the value of select field. This is the sample code I have written in ADT<br /><#if entries?has_content><br /> <#list entries as curEntry><br /> <#assign renderer = curEntry.getAssetRenderer()><br /> <#assign className = renderer.getClassName()><br /> <#assign article = renderer.getArticle() ><br /> <#if className == "com.liferay.journal.model.JournalArticle"><br /> <#assign document = saxReaderUtil.read(article.getContent()) ><br /> <#assign rootElement = document.getRootElement() ><br /> <#list rootElement.elements() as dynamicElement ><br /> <#if "body" == dynamicElement.attributeValue("name") ><br /> <#assign title= dynamicElement.element("dynamic-content").getText() ><br /> <strong>${title} </strong><br /> </#if><br /> </#if><br /> </#list><br /></#