您好,我已经创建了一个简单的结构,其中只有一个可重复的web内容字段。在我的模板中,我有以下代码:
<#if WebContent75zf.getSiblings()?has_content>
<#list WebContent75zf.getSiblings() as cur_WebContent75zf>
<!-- Web Content Start -->
${cur_WebContent75zf.getData()}
<!-- Web Content End -->
</#list>
</#if>期望的结果是要么显示所呈现的每个web内容,要么至少获得它们的数据。我得到的是以下内容,我想知道我是不是做错了什么…
<!-- Web Content Start -->
{"className":"com.liferay.journal.model.JournalArticle","classPK":"40952"}
<!-- Web Content End -->
<!-- Web Content Start -->
{"className":"com.liferay.journal.model.JournalArticle","classPK":"40971"}
<!-- Web Content End -->
<!-- Web Content Start -->
{"className":"com.liferay.journal.model.JournalArticle","classPK":"40990"}
<!-- Web Content End --> 发布于 2017-09-07 18:08:47
这个:{"className":"com.liferay.journal.model.JournalArticle","classPK":"40971"}是通过JournalArticleLocalService检索所选网页内容所需的内容,您只需像这样获取classPK:
<#if WebContent75zf.getSiblings()?has_content>
<#list WebContent75zf.getSiblings() as cur_webContent>
<#assign cur_webContent_map = cur_webContent.getData()?eval>
<#assign cur_webContent_classPK = cur_webContent_map.classPK>
<#assign article = JournalArticleLocalService.getLatestArticle(cur_webContent_classPK?number)>
</#list>
</#if>发布于 2018-07-17 00:13:13
这在Liferay 7.0中有效。确保在Liferay设置中禁用了受限变量
<#-- Liferay 7.0 -->
<#-- Make sure restricted variables are disabled in Liferay settings -->
<#assign
serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext()
themeDisplay = serviceContext.getThemeDisplay()
group_id = themeDisplay.getScopeGroupId()
JournalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService")
>
<#if WebContent75zf.getSiblings()?has_content>
<#list WebContent75zf.getSiblings() as cur_webContent>
<#assign
cur_webContent_map = cur_webContent.getData()?eval
cur_webContent_classPK = cur_webContent_map.classPK
article = JournalArticleLocalService.getLatestArticle(cur_webContent_classPK?number)
article_id = article.articleId
article_content = JournalArticleLocalService.getArticleContent(group_id, article_id, null, locale, themeDisplay)
>
${article_content}
</#list>
</#if>发布于 2018-06-15 06:36:51
在使用journalArticleLocalService之前先定义它:
serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") journalArticleLocalService = <#assign />
https://stackoverflow.com/questions/46054810
复制相似问题