If we want to fetch the journal article of web content
details in template file then the following code will be usefull.
The following code will shows the tag based journal Article
content in template.
#set($assetTag =$serviceLocator.findService('com.liferay.portlet.asset.service.AssetTagLocalService'))
#set($assetEntryService =$serviceLocator.findService('com.liferay.portlet.asset.service.AssetEntryLocalService'))
#set($journalArticleResourceLocal=$serviceLocator.findService('com.liferay.portlet.journal.service.JournalArticleResourceLocalService'))
#set($journalArticleLocal=$serviceLocator.findService('com.liferay.portlet.journal.service.JournalArticleLocalService'))
#set($journalContentUtil =$utilLocator.findUtil('com.liferay.portlet.journalcontent.util.JournalContent'))
#set($groupId = $getterUtil.getLong($groupId))
#set($languageId = $request.theme-display.language-id)
#set($assetTagObj=$assetTag.getTag($groupId,"myTag"))
#set($assetId = $assetTagObj.getTagId())
#set($assestList= $assetEntryService.getAssetTagAssetEntries($assetId))
#set($assetEntry = "")
#foreach($assetEntry in $assestList)
#set($journalArticleResource =$journalArticleResourceLocal.getJournalArticleResource($assetEntry.getClassPK()))
#set($journalArticle = $journalArticleLocal.getArticle($groupId,$journalArticleResource.getArticleId()))
#set($latestArticle= $journalArticleLocal.getLatestArticle($groupId,$journalArticle.getArticleId()))
#set( $journalArticleDisplay= $journalContentUtil.getDisplay($groupId,$latestArticle.getArticleId(), null,null,$languageId,null, 1, $xmlRequest))
$journalArticleDisplay.getContent()
#end
No comments:
Post a Comment