您好我创建了一个只有1个可重复的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 -->
答案 0 :(得分:1)
这个:{"className":"com.liferay.journal.model.JournalArticle","classPK":"40971"}
是你通过JournalArticleLocalService检索所选Web内容所需要的,你只需得到这样的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>
答案 1 :(得分:0)
在使用之前定义journalArticleLocalService:
&lt; #assign journalArticleLocalService = serviceLocator.findService(&#34; com.liferay.journal.service.JournalArticleLocalService&#34;)/&gt;
答案 2 :(得分:0)
这在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>