在Liferay Web内容模板中获取页面查看和上次更新日期

时间:2016-06-02 21:22:26

标签: liferay liferay-6 freemarker

我需要包含上次更新网页内容的日期以及在Liferay 6.1网络内容模板中查看网页内容的次数。

最好的方法是什么?

1 个答案:

答案 0 :(得分:1)

速度 对于修改日期,您可以使用变量$reserved-article-modified-date.data和视图计数

#set ($groupId = $themeDisplay.getLayout().getGroupId())
#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($ja = $journalArticleLocalService.getArticle($getterUtil.getLong($groupId),$getterUtil.getString($reserved-article-id.data)))
#set ($resourceprimKey = $ja.getResourcePrimKey())
#set ($assetEntryLocalService = $serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService"))
#set ($assetEntry = $assetEntryLocalService.getEntry("com.liferay.portlet.journal.model.JournalArticle", $resourceprimKey))


count view = $assetEntry.viewCount

Freemarker的

<#assign JournalArticleLocalService = serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService")>
 <#assign assetLinkLocalService = serviceLocator.findService("com.liferay.portlet.asset.service.AssetLinkLocalService" )>
 <#assign assetEntryLocalService = serviceLocator.findService("com.liferay.portlet.asset.service.AssetEntryLocalService" )>
 <#assign getterUtil = staticUtil["com.liferay.portal.kernel.util.GetterUtil"] />
 <#assign currentArticle = JournalArticleLocalService.getArticle(getterUtil.getLong(groupId),.vars['reserved-article-id'].data)>
 <#assign currentArticleResourcePrimKey = currentArticle.getResourcePrimKey()>
 <#assign currentArticleAssetEntry = assetEntryLocalService.getEntry("com.liferay.portlet.journal.model.JournalArticle", currentArticleResourcePrimKey)/>

 view count = ${currentArticleAssetEntry.viewCount}
modifydate = ${.vars['reserved-article-modified-date'].data}