Fórumok

Need portal theme personalization on user level

thumbnail
Dhandapani S, módosítva 12 év-val korábban

Need portal theme personalization on user level

Regular Member Bejegyzések: 176 Csatlakozás dátuma: 2009.03.24. Legújabb bejegyzések
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
thumbnail
Jan Gregor, módosítva 12 év-val korábban

RE: Need portal theme personalization on user level

Regular Member Bejegyzések: 224 Csatlakozás dátuma: 2010.10.20. Legújabb bejegyzések
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.
thumbnail
Dhandapani S, módosítva 11 év-val korábban

RE: Need portal theme personalization on user level

Regular Member Bejegyzések: 176 Csatlakozás dátuma: 2009.03.24. Legújabb bejegyzések
Hi,

Is there any solution?
thumbnail
Muzakir Khan, módosítva 11 év-val korábban

RE: Need portal theme personalization on user level

Regular Member Bejegyzések: 112 Csatlakozás dátuma: 2012.03.15. Legújabb bejegyzések
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..
thumbnail
Sachin Mane, módosítva 11 év-val korábban

RE: Need portal theme personalization on user level

Junior Member Bejegyzések: 76 Csatlakozás dátuma: 2012.04.10. Legújabb bejegyzések
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


long userGroupId = user.getGroup().getGroupId ();

// Update public page layouts
LayoutSetLocalServiceUtil.updateLookAndFeel(
			userGroupId, false, "<theme id>", "01 <colorschemeid>", "",
			false);
// Update private page layouts
LayoutSetLocalServiceUtil.updateLookAndFeel(
			userGroupId, true, "<theme id>", "01 <colorschemeid>", "",
			false);

</colorschemeid></theme></colorschemeid></theme>

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
thumbnail
Dhandapani S, módosítva 11 év-val korábban

RE: Need portal theme personalization on user level

Regular Member Bejegyzések: 176 Csatlakozás dátuma: 2009.03.24. Legújabb bejegyzések
Hi Sachin,

I don't want only for user public/private pages,,, i need to provide options to change the community themes for users.
thumbnail
Dhandapani S, módosítva 11 év-val korábban

RE: Need portal theme personalization on user level

Regular Member Bejegyzések: 176 Csatlakozás dátuma: 2009.03.24. Legújabb bejegyzések
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.
thumbnail
Sachin Mane, módosítva 11 év-val korábban

RE: Need portal theme personalization on user level

Junior Member Bejegyzések: 76 Csatlakozás dátuma: 2012.04.10. Legújabb bejegyzések
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 -
servlet.service.events.pre=com.liferay.portal.events.ServicePreAction, com.test.CustomServicePreAction


3. In CustomServicePreAction, you read User's preferences for layout and change following -
request.setAttribute(WebKeys.THEME, theme);
	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.