Tuesday 15 July 2014

Display Dockbar based on Roles in Liferay


Below code can be used to check logged in user is Admininstrator then display Dockbar:#if ($permissionChecker.isOmniadmin())#dockbar()#end

Below code snippet is used to show/hide dockbar based on custom Role. If logged in user has custom Role assigned, then dockbar shall be visible to him. It shall be hidden for rest of users.

#if ( $is_signed_in )        #set ($roleService = $serviceLocator.findService("com.liferay.portal.service.RoleService"))    #set ($listOfUserRoles = $roleService.getUserRoles( $user_id ))    #foreach( $userRole in $listOfUserRoles)       #if ($userRole.getName() == "Custom-Role")          #dockbar()       #end    #end#end