Showing posts with label template. Show all posts
Showing posts with label template. Show all posts

Wednesday, December 26, 2012

Template : some important variable in template(.vm)

Hi All,

   Many time we use webcontent OOTB functionality for our solution. for that we also use Structure/Template. here Template is render part of WebContent. so many time developer stuck with how to get value of some important properties like theme-dispaly,scopegroupid,image path, etc. so, here give some instruction for that.

1) to get instance of class (some times we can't get accesss class by serviceLocator.findService())
$portal.getClass().forName("com.liferay.portlet.dynamicdatamapping.storage.StorageEngineUtil").newInstance()   

2)currentScopegroupid 
    - $getterUtil.getLong($request.get("theme-display").get("scope-group-id"))
    - $request.theme-display.scope-group-id
3) images path in theme
    $request.get("theme-display").path-theme-images
4) themeDispaly
    $request.theme-display
5) globalScopeGroupId
    $groupId

5) find service
 $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService")


Enjoy!!!

Wednesday, December 19, 2012

Servidce/Util classes access in template (.vm) file in Liferay

Hi Developers,

Many times you need to access services/util class in template. 

Below is some importance hits for the same.

=> Access services using findService method in Velocity(vm)

#set ($userLocalService= $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
=>Access util class using  findUtil Method for inbuilt Util of Liferay
#set ($journalContentUtil = $utiLocator.findUtil("com.liferay.portlet.journalcontent.util.JournalContentUtil"))
=> some times you also need to access util class which is not have access in template file like StorageEngineUtil. for that you can use below approch..

#set ($util = $portal.getClass().forName("com.liferay.portlet.dynamicdatamapping.storage.StorageEngineUtil").newInstance()) 


HTH.. :))