michael
michael

Reputation: 16341

different Style for Users with different Roles in Liferay

is it possible to set a different CSS-style for users with different roles in the liferay portal server. e.g. a user has the role admin set

{
background-color: blue; 
}

is it's a user with the role editor set the

{
background-color:yellow;
}

for sure these are just examples.

thx.

Upvotes: 2

Views: 165

Answers (1)

Mark
Mark

Reputation: 18767

Yes, that is possible. Herefore you need to create new Theme-Plugin see http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/creating-themes-and-layout-templates-liferay-portal-6-2-dev-guide-09-en

and customized e.g. portal_normal.vm

something like this (similar docbar visibility):

...
#if ($is_signed_in)
  #set ($rService = $serviceLocator.findService("com.liferay.portal.service.RoleService"))
  #set ($roleColor = 'white')
  #if($rService.hasUserRole($user_id, $company_id, "Administrator", true ))
    #set ($roleColor = 'blue')
  #end
  #if($rService.hasUserRole($user_id, $company_id, "Editor", true ))
      #set ($roleColor = 'red')
  #end
#end

<div id="role-color" class="$roleColor">
...

attention: by the order of if-statements you can set what matter by users that are admin & editor.

Upvotes: 3

Related Questions