문제

Is it possible to increment view count of asset entry programically from velocity template?

Thanks for all answers.

도움이 되었습니까?

해결책

It should be possible, after all its just about updating a liferay entity.

If you can get hold of AssetEntryService then you can call the method incrementViewCounter which would increment the view counter by 1.

So in your template you would have code like this:

#set ($assetEntryService = $serviceLocator.findService('com.liferay.portlet.asset.service.AssetEntryService'))
$assetEntryService.incrementViewCounter(String className, long classPK)

If you want to specify the increment value instead of the default 1, then you would require the instance of AssetEntryLocalService as follows:

#set ($assetEntryLocalService = $serviceLocator.findService('com.liferay.portlet.asset.service.AssetEntryLocalService'))
$assetEntryService.incrementViewCounter(long userId, String className, long classPK, long increment)

increment = to increment the current viewCount by this value.

I hope I have understood what was required.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top