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

3 comments:

  1. Hi , Please help me for the above thing for custome roles
    I created new regular role with PSS and assigned one user to that role and above code was copied into portal_normal.vm file in custome Theme. Please find the below code.

    #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() == "PSS")
    #dockbar()
    #end
    #end
    #end

    But the below code is not working . Please kindly help me for that . But here just I created regular role .

    ReplyDelete
  2. Hi , Please help me for the above thing for custome roles
    I created new regular role with PSS and assigned one user to that role and above code was copied into portal_normal.vm file in custome Theme. Please find the below code.

    #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() == "PSS")
    #dockbar()
    #end
    #end
    #end

    But the below code is not working . Please kindly help me for that . But here just I created regular role .

    ReplyDelete
  3. Please reply any one for the above issue

    ReplyDelete