Showing posts with label journal article id in template. Show all posts
Showing posts with label journal article id in template. Show all posts

Thursday, April 10, 2014

Fetching JournalArticle object in Template

To fetch journal article id in template we are having variable : $reserved-article-id.data

Below code is used for fetching JournalArticle object in Template:

#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($journalArticle = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId),$getterUtil.getString($reserved-article-id.data)))
 Below code is used for fetching User object in Template
#set ($userLocalService= $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($user = $userLocalService.getUserById($getterUtil.getLong($request.get("theme-display").get("user-id"))))

Note:Template should not be Cacheable otherwise always you will get same userid from request object