在 Liferay Web 内容模板中获取页面浏览量和上次更新日期

Getting page views and last updated date within a Liferay Web Content Template

我需要在我的 Liferay 6.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

自由标记

<#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}