Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: ADT in Liferay 7.1
<#if entries?has_content>
<#list entries as curEntry>
<#assign renderer = curEntry.getAssetRenderer() />
<#assign thumbnailPath = renderer.getThumbnailPath(renderRequest) />
<#assign classe = renderer.getClassName() />
<#if classe == "com.liferay.journal.model.JournalArticle">
<#assign journalArticle = renderer.getArticle() />
<#assign document = saxReaderUtil.read(journalArticle.getContent()) />
<#assign rootElement = document.getRootElement() />
<#assign xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='imagem']") />
<#assign image = xPathSelector.selectSingleNode(rootElement).getStringValue() />
<#assign xPathSelector2 = saxReaderUtil.createXPath("dynamic-element[@name='conteudo']") />
<#assign conteudo = xPathSelector2.selectSingleNode(rootElement).getStringValue() />
<p> ${curEntry.getTitle(locale)} ${curEntry.getDescription(locale)} <img src="${thumbnailPath}"> </p>
<p><img src="${image}"></p>
<p>${conteudo}</p><p>
</p><p><a href="/web/guest/mais-noticias/-/asset_publisher/oJL9Y5ehvOlQ/content/${renderer.getUrlTitle()}">
Link
</a></p>
<!--#if-->
<!--#list-->
<!--#if-->
Hi,
I had the same problem. This code worked in Liferay 7.1 .
Basicly you need to build the path with the JSON, for this need use
the JsonFactoryUtil to convert the String result to JSON and you can
access to all atributtes.
<#if entries?has_content>
<#list entries as
curEntry>
<#assign renderer =
entry.getAssetRenderer()>
<#assign journalArticle
= renderer.getArticle()>
<#assign document =
saxReaderUtil.read(journalArticle.getContent()) >
<#assign rootElement = document.getRootElement()>
<#assign xPathSelector =
saxReaderUtil.createXPath("dynamic-element[@name='NAME_VAR']")>
<#assign imgNews =
xPathSelector.selectSingleNode(rootElement).getStringValue()>
<#assign imgJson =
jsonFactoryUtil.createJSONObject(imgNews)>
<#assign url = "/documents/"+ imgJson.groupId
+"/" +imgJson.fileEntryId +"/"+ imgJson.name
+"/"+imgJson.uuid >
<img
src="${url}">
</#list>
</#if>
Regards.
PS: You own me one beer.
I'm using 7.2 GA1 CE.
I had to edit one field though.
The imgJson value was:
{
"groupId": "14503",
"alt": "",
"name": "673323",
"title": "673323",
"type": "journal",
"uuid": "15a970d0-1a0e-f067-2910-f513466da6fa",
"resourcePrimKey": "172374"
}
So instead of imgJson.fileEntryId, I had to put resourcePrimKey.
Thanks again!
Sincerely,
Yannik
Thanks for that !