Problem: I want to use web content display portlet to display articles dynamically (i.e) I will pass article-id as an argument to page and web content display portlet has to read the article-id and display the content.
Solution:
The above problem can be solved by creating an template. Have the below script in your template.
Sample URL for page would be http://localhost:8080/web/carlovers/dynamic-page?articleId=10712
Solution:
The above problem can be solved by creating an template. Have the below script in your template.
Sample URL for page would be http://localhost:8080/web/carlovers/dynamic-page?articleId=10712
## Get Article Id from the request URL #set ($current_url = $request.get("attributes").CURRENT_COMPLETE_URL) #set ($paramName='articleId') #set ($articleId = $httpUtil.getParameter($current_url, $paramName)) #set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService")) ## Get article based on article id #set ($article = $journalArticleLocalService.getArticle($getterUtil.getLong($request.theme-display.scope-group-id),$articleId)) ## display relavent information $article.getUrlTitle() $article.getContentByLocale($request.theme-display.language-id)
No comments:
Post a Comment