Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dhandapani S
Need portal theme personalization on user level
March 6, 2012 10:45 PM
Answer

Dhandapani S

Rank: Regular Member

Posts: 156

Join Date: March 24, 2009

Recent Posts

Hi All,

I want to allow user to change theme for the portal with their personalization. Say for example, I have deployed Theme1 and Theme2 in my portal.

If User1logged in, he can change the theme as Theme1 for him. and User2 logged in he can change the theme as Theme2 for him. So when ever user 1 is login , the site should be look in theme1, and user 2 login , site should be in theme2. Its like igoogle.

How can i achieve this.? please help me or guide me .....

Thanks in advance.

Regards

Dhandapani S
Jan Gregor
RE: Need portal theme personalization on user level
March 6, 2012 11:13 PM
Answer

Jan Gregor

Rank: Regular Member

Posts: 224

Join Date: October 20, 2010

Recent Posts

Hi there,

This is possible to achieve, by creating a hook. Anyways, it is not trivial, so i would first have a look at hooks and object called themeDisplay. This basically stores all informations about curent shown pages, layouts, themes etc and you can access it on runtime by creating a hook.

Regards,
Jan.
Dhandapani S
RE: Need portal theme personalization on user level
July 2, 2012 9:54 PM
Answer

Dhandapani S

Rank: Regular Member

Posts: 156

Join Date: March 24, 2009

Recent Posts

Hi,

Is there any solution?
Muzakir Khan
RE: Need portal theme personalization on user level
July 2, 2012 10:21 PM
Answer

Muzakir Khan

Rank: Regular Member

Posts: 112

Join Date: March 14, 2012

Recent Posts

Jan Gregor:
Hi there,

This is possible to achieve, by creating a hook. Anyways, it is not trivial, so i would first have a look at hooks and object called themeDisplay. This basically stores all informations about curent shown pages, layouts, themes etc and you can access it on runtime by creating a hook.

Regards,
Jan.


This is the solution..emoticonemoticon..
Sachin Mane
RE: Need portal theme personalization on user level
July 2, 2012 10:31 PM
Answer

Sachin Mane

Rank: Junior Member

Posts: 76

Join Date: April 9, 2012

Recent Posts

Hi Dhandapani,

This is possible because of the fact that every user has his own set of public and private pages and theme can vary page to page.
I am assuming you are talking about only changing the theme of user's pages. There could be other common pages like community, organization or portal instance. These pages will be common across users.

If you want to dynamically change the theme of user's public/private pages, then according to me the design should be as follows -
1. Create a portlet which you will place on user's private page. This portlet will fetch all the themes deployed using ThemeLocalServiceUtil.getThemes ()
2. Display all the theme names a drop list and allow user to chose. Submit the choice to portlets processAction () method.
3. In portlet's process action method, use following API to update user's private and public page theme

 1
 2long userGroupId = user.getGroup().getGroupId ();
 3
 4// Update public page layouts
 5LayoutSetLocalServiceUtil.updateLookAndFeel(
 6            userGroupId, false, "<theme id>", "01 <colorSchemeId>", "",
 7            false);
 8// Update private page layouts
 9LayoutSetLocalServiceUtil.updateLookAndFeel(
10            userGroupId, true, "<theme id>", "01 <colorSchemeId>", "",
11            false);

Theme id will be in a format <themname>_WAR_<war file name without _> e.g. sevencogs_WAR_sevencogstheme
If your theme supports color schemes then you can also specify color scheme. if not use 1st i.e. 01
Dhandapani S
RE: Need portal theme personalization on user level
July 2, 2012 11:01 PM
Answer

Dhandapani S

Rank: Regular Member

Posts: 156

Join Date: March 24, 2009

Recent Posts

Hi Sachin,

I don't want only for user public/private pages,,, i need to provide options to change the community themes for users.
Dhandapani S
RE: Need portal theme personalization on user level
July 2, 2012 11:19 PM
Answer

Dhandapani S

Rank: Regular Member

Posts: 156

Join Date: March 24, 2009

Recent Posts

Hi Sachin,

I seen one website which has the feature of changing color scheme....

http://www.kln.gov.my/web/guest/home


I need to implement similar like that but in my scenario,,, the application will be landing after user logged in only.... there is no guest pages..... so authentication is mandatory... so once user logged in, they will be landing one community home page.... if user changed the theme, it should reflect to whole community.... So further whenever that user logged in, the site should be load in that new theme which user changed.

Thanks in advance.
Sachin Mane
RE: Need portal theme personalization on user level
July 3, 2012 1:31 AM
Answer

Sachin Mane

Rank: Junior Member

Posts: 76

Join Date: April 9, 2012

Recent Posts

Okay. So you want to have dynamic theme to your community pages as well.

Here is what i think you will have to do.

1. Create a custom ServicePreAction class and chain it after original ServicePreAction class. Refer to http://www.liferay.com/community/wiki/-/wiki/Main/Page+Rendering for details on how page is rendered and the role of Service pre action.

2. Service pre action events are configured in portal.properties as follows -
1servlet.service.events.pre=com.liferay.portal.events.ServicePreAction, com.test.CustomServicePreAction


3. In CustomServicePreAction, you read User's preferences for layout and change following -
1request.setAttribute(WebKeys.THEME, theme);
2    request.setAttribute(WebKeys.COLOR_SCHEME, colorScheme);


Refer to the source code of ServicePreAction on how these values are set in request attributes.

4. What this essentially does is - it changes the theme and colorScheme just before the page is rendered. Here you can have your logic to read the theme and colorScheme selected by the user and change it.

5. You can write a portlet to allow user to select the theme and store in some table in liferay. You can generate that code using ServiceBuilder.