0x_Anakin
0x_Anakin

Reputation: 3269

Liferay retrieve specific web content from velocity template

I'm trying to retrieve other web contents / articles from inside another a velocity template.

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

Upvotes: 0

Views: 1680

Answers (1)

Ashish Dadhich
Ashish Dadhich

Reputation: 5285

Use getLatestArticle method when you want to get latest article from list of articles. Checkout the below link.

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

Upvotes: 0

Related Questions