简体   繁体   English

Liferay从速度模板中检索特定的Web内容

[英]Liferay retrieve specific web content from velocity template

I'm trying to retrieve other web contents / articles from inside another a velocity template. 我正在尝试从另一个速度模板内部检索其他Web内容/文章。

What I would like to to get is a list with published articles of the latest version with structure name 'Game'. 我想得到的是一个列表,其中包含结构名称为“游戏”的最新版本的已发布文章。 I tried to use search but with no luck at all. 我尝试使用搜索,但没有运气。 At the moment I have something like the following but still I don't have the result I want. 目前,我有类似以下内容,但仍然没有想要的结果。

#set ($journalArticleLocalService = $serviceLocator.findService('com.liferay.portlet.journal.service.JournalArticleLocalService'))
#set ($languageId = $request.theme-display.language-id)
#set ($companyId = $getterUtil.getLong($request.theme-display.company-id))
#set ($scopeGroupId = $getterUtil.getLong($request.theme-display.scope-group-id))
#set ($DDMStructureLocalService = $serviceLocator.findService("com.liferay.portlet.dynamicdatamapping.service.DDMStructureLocalService"))
#set ($structures = $DDMStructureLocalService.getStructures($scopeGroupId)) 
#set ($obc = $portal.getClass().forName("com.liferay.portlet.journal.util.comparator.ArticleDisplayDateComparator").newInstance())

#foreach ($tmp in $structures)

    #if ($tmp.getName($languageId) == 'Game') 
        #set ($allArticles = $journalArticleLocalService.getStructureArticles($scopeGroupId, $tmp.getStructureKey()))

    #end

#end

#foreach ($article in $allArticles)

    #if ($article.getStatus() == 0)
        <pre>    $article    </pre>
    #end

#end

I'm using Liferay 6.2 sp8 with some extra patches 我正在使用Liferay 6.2 sp8和一些额外的补丁

Use getLatestArticle method when you want to get latest article from list of articles. 如果要从文章列表中获取最新文章,请使用getLatestArticle方法。 Checkout the below link. 查看以下链接。

https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portlet/journal/service/JournalArticleLocalServiceUtil.html#getLatestArticle(long, java.lang.String)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM