Problem: Want to list all the assets related to a category.
Solution: Below template takes category name as parameter in the URL and lists all the assets that relates to provided category
Solution: Below template takes category name as parameter in the URL and lists all the assets that relates to provided category
#set ($current_url = $request.get("attributes").CURRENT_COMPLETE_URL) #set ($paramName='categoryName') #set ($catName = $httpUtil.getParameter($current_url, $paramName)) #set ( $AssetCategoryLocalService = $serviceLocator.findService( "com.liferay.portlet.asset.service.AssetCategoryLocalService" )) #set ( $CatListDQ = $AssetCategoryLocalService.getCategories() ) #foreach( $catItem in $CatListDQ ) #if($catItem.getName()==$catName) #set ( $catId=$catItem.getCategoryId()) #end #end #set ( $assetEntryQuery = $portal.getClass().forName( "com.liferay.portlet.asset.service.persistence.AssetEntryQuery" ).newInstance()) #set ( $V = $assetEntryQuery.setAllCategoryIds( $catId)) #set ( $acsUtil = $portal.getClass().forName( "com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil" ).newInstance()) #set ( $AssetEntryList = $acsUtil.getEntries( $assetEntryQuery )) #foreach( $asset in $AssetEntryList ) $asset.getTitle() #end
No comments:
Post a Comment