论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Dhandapani S
Need portal theme personalization on user level
2012年3月6日 下午10:45
答复

Dhandapani S

等级: Regular Member

帖子: 170

加入日期: 2009年3月24日

最近的帖子

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
2012年3月6日 下午11:13
答复

Jan Gregor

等级: Regular Member

帖子: 224

加入日期: 2010年10月20日

最近的帖子

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
2012年7月2日 下午9:54
答复

Dhandapani S

等级: Regular Member

帖子: 170

加入日期: 2009年3月24日

最近的帖子

Hi,

Is there any solution?
Muzakir Khan
RE: Need portal theme personalization on user level
2012年7月2日 下午10:21
答复

Muzakir Khan

等级: Regular Member

帖子: 112

加入日期: 2012年3月14日

最近的帖子

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
2012年7月2日 下午10:31
答复

Sachin Mane

等级: Junior Member

帖子: 76

加入日期: 2012年4月9日

最近的帖子

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
2012年7月2日 下午11:01
答复

Dhandapani S

等级: Regular Member

帖子: 170

加入日期: 2009年3月24日

最近的帖子

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
2012年7月2日 下午11:19
答复

Dhandapani S

等级: Regular Member

帖子: 170

加入日期: 2009年3月24日

最近的帖子

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
2012年7月3日 上午1:31
答复

Sachin Mane

等级: Junior Member

帖子: 76

加入日期: 2012年4月9日

最近的帖子

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.