Forums de discussion
How to apply theme for user's private pages
Dinesh Balaji, modifié il y a 13 années.
How to apply theme for user's private pages
Junior Member Publications: 51 Date d'inscription: 06/10/10 Publications récentes
Hi All !
I want to apply theme for user's private pages in a programmatic manner. For this, I have created a hook and i hard-coded the users and i set the condition to apply theme for particular user's private pages. I didn't get any errors and the problem was the theme is not applied for particular user(Default is applied ). Here is my code :
Can anyone suggest me how to achieve this ?
Thanks in advance.
Regards,
Dinesh
I want to apply theme for user's private pages in a programmatic manner. For this, I have created a hook and i hard-coded the users and i set the condition to apply theme for particular user's private pages. I didn't get any errors and the problem was the theme is not applied for particular user(Default is applied ). Here is my code :
package com.sample.hook;
import com.liferay.portal.kernel.events.Action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.liferay.portal.kernel.events.Action;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.struts.LastPath;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.liferay.portal.service.ThemeLocalServiceUtil;
import com.liferay.portal.model.Theme;
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
public class LoginAction extends Action
{
public void run(HttpServletRequest req, HttpServletResponse res) throws ActionException
{
System.out.println(":entry 1");
try {
long userId = PortalUtil.getUserId(req);
User user = UserLocalServiceUtil.getUser(userId);
Theme theme = null;
if(user.getFullName().equals("test1"))
{
LayoutSetLocalServiceUtil.updateLookAndFeel(1, "theme-1", " ", " ", false);
}
else if(user.getFullName().equals("test2"))
{
LayoutSetLocalServiceUtil.updateLookAndFeel(1, "theme-2", " ", " ", false);
}
}
catch (PortalException ex)
{
System.out.println("Portal Error");
}
catch (Exception ex)
{
System.out.println("General Error");
}
}
}
Can anyone suggest me how to achieve this ?
Thanks in advance.
Regards,
Dinesh
jelmer kuperus, modifié il y a 13 années.
RE: How to apply theme for user's private pages
Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentesLayoutSetLocalServiceUtil.updateLookAndFeel(user.getGroup().getGroupId(), themeId, colorSchemeId, "", false);
where themeId is the unique theme id. Suppose you built your own theme called my-theme and deployed it as a war then your themeId would be my_WAR_mytheme
for colorSchemeId you would typically use "01"
Tanaji M. Londhe, modifié il y a 10 années.
RE: How to apply theme for user's private pages
Regular Member Publications: 194 Date d'inscription: 25/04/12 Publications récentes
Hi Jelmer,
while applying theme for pages, how do you differentiate that page are public or private.
Beacuse when i update look and feel, it apply only for public pages.
while applying theme for pages, how do you differentiate that page are public or private.
Beacuse when i update look and feel, it apply only for public pages.
Sharad Sinha, modifié il y a 10 années.
RE: How to apply theme for user's private pages
Junior Member Publications: 44 Date d'inscription: 08/03/13 Publications récentes
Hi Tanaji,
You can differentiate user's private and public page by using
layout.isPrivateLayout()
Try to update theme for user's private page with this code:
I hope this will help you.
Thanks
Sharad Sinha
You can differentiate user's private and public page by using
layout.isPrivateLayout()
Try to update theme for user's private page with this code:
LayoutLocalServiceUtil.updateLookAndFeel(groupId, // GroupId not Scope groupId
true, // public layout or private layout ( True if you want to update theme for private page)
LayoutId, // Layout Id
ThemeId, // ThemeId
ColorSchemeId, // color SchemeId
css, //CSS
Wap // true or false for Wap theme
);
I hope this will help you.
Thanks
Sharad Sinha