0

I want such a mechanism that will provide different themes depends on different user roles in Liferay.Is there a way that provide me a solution that i can change theme on User roles. Secondly i want to know that is this is possible programatically or Liferay provides custom supports with this.

any help will be greatly appreciated.

Ali
  • 557
  • 1
  • 9
  • 30
  • I have not tried this but can you write hook to override `servlet.service.events.pre` and provide your custom implementation same as ThemeServicePreAction.java and write logic to change theme attribute in request based on user's role. HTH – Pankaj Kathiriya May 21 '14 at 06:12

3 Answers3

0

Bad choice

The right way is not to change the theme but to inject something in the page to alter the style.

It's a bad idea to change the theme at runtime depending on the user session. Poor performance due to the invalidated cache every request.

Build a custom portlet and inject it into the theme for every page. Depending on user logic that portlet can inject some javascript to alter css class of html tag.

Is it clear?

Daniele Baggio
  • 2,157
  • 1
  • 14
  • 21
  • wat do you say abt this blog https://digitalfireflymarketing.com/how-select-multiple-themes-liferay – Alex Man Dec 26 '15 at 16:43
  • It's possible, but for real world project is not a solution. – Daniele Baggio Dec 26 '15 at 17:04
  • so you meant to say something like, say we are providing three themes themeA, themeB, themeC. each one differ the color, font and other change based on a css file, sy if a userA selects themeA save the theme name under a custom column named theme in user table, and based on the input we have to import the corresponding css file – Alex Man Dec 26 '15 at 17:43
0

Theme is associated with layout (i.e. page). This can be observed in Layout table of liferay. So, even it can be changed using API, but not something that is different at user level, but its associated at page level.

For your requirement, If you have some fixed number of themes, then having different Sites each having one particular theme been applied.

Using Post login hook, you can check for user role and redirect to appropriate site. Having this approach you can have completely different layout and pages as well depending on user role if you wish you.

Haris
  • 1,131
  • 7
  • 20
0

We can also use velocity variables such $is_male, $is_female, $time_zone, $language.. to identify user group and can load different CSS file or a parent class in body tag.

Answer might be not useful for Mark who has raised this but future reader might find this useful.

Thanks

Vasimkhan
  • 323
  • 1
  • 11