Last active
May 18, 2017 02:17
-
-
Save dlfinis/1cb6ab81f38254e5a9d7 to your computer and use it in GitHub Desktop.
Web Content Liferay access to Journal Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Check that have added these properties in the portal-ext.properties file | |
journal.template.velocity.restricted.variables= | |
velocity.engine.restricted.classes= | |
velocity.engine.restricted.variables= | |
## Way to add a web content by id | |
#set ($group_id = $getterUtil.getLong($request.theme-display.scope-group-id)) | |
#set ($webcontent-id = "0101") | |
#set ($webcontent=$journalContentUtil.getContent($group_id, $webcontent-id, "", "$locale", "")) | |
## Way to get a article of a web content by the urlTitle(This is the name of web content published in lowercase and without space{An space will become an '-'}) | |
#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService")) | |
#set ($journalArticle = $journalArticleLocalService.getArticleByUrlTitle($getterUtil.getLong($groupId),"test-menu")) | |
## Way to get an Article by IdArticle and GroupId | |
#set ($journalArticleName = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId),$getterUtil.getString("21729")).getName()) | |
## Way to get the folder Object of the web content | |
$journalArticle.getFolder() | |
########################################### | |
## Manipulation of object DDM in Liferay | |
## Get an DDMStructureLocalServiceUtil Object | |
#set ($DDMStructureLocalService = $serviceLocator.findService("com.liferay.portlet.dynamicdatamapping.service.DDMStructureLocalService")) | |
## Get an JournalArticleLocalServiceUtil Object | |
#set ($journalLocalServiceUtil = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService")) | |
## Get the current groupId | |
#set ($group_id = $getterUtil.getLong($request.theme-display.scope-group-id)) | |
## Get the all structures in the Portal | |
#foreach ($ddm in $DDMStructureLocalService.getStructures()) | |
$ddm.getName() $ddm.getStructureId() $ddm.getStructureKey() | |
</br> | |
## Get the all templates that use a structure | |
#foreach ($tddm in $ddm.getTemplates()) | |
$tddm.getTemplateId() | |
</br> | |
## Get the all articles that use a template | |
#foreach ($addm in | |
$journalArticleLocalService.getTemplateArticles($getterUtil.getLong($group_id),$tddm.getTemplateKey())) | |
$addm.getUrlTitle() | |
#end | |
#end | |
</br> | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment