Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Liferay 7.2 - Define a specific look and feel for a page programmatically
Hi,
I have been creating my pages programmatically like this:
Now I am trying to set the theme like this:
The problem is that the page is created, but the theme is not updated. I am pretty sure, the problem is that when the page is created the "Look and Feel" is by default Use the same look and feel of the Public Pages."and because of that my custom theme is not applied. How to I set my layout "Look and Feel" to be by default to "Define a specific look and feel for this page."?
I have been creating my pages programmatically like this:
Layout layout = LayoutLocalServiceUtil.fetchLayoutByFriendlyURL(myGroupId, false, myPageUrl);
if (layout == null) layout = LayoutLocalServiceUtil.addLayout(
myUserId,
myGroupId,
false,
LayoutConstants.DEFAULT_PARENT_LAYOUT_ID,
myPageName,
null,
null,
LayoutConstants.TYPE_PORTLET,
false,
myPageUrl,
new ServiceContext()
);
Now I am trying to set the theme like this:
LayoutLocalServiceUtil.updateLookAndFeel(
layout.getGroupId(),
layout.getPrivateLayout(),
layout.getLayoutId(),
myThemeId,
layout.getColorSchemeId(),
layout.getCss()
);
The problem is that the page is created, but the theme is not updated. I am pretty sure, the problem is that when the page is created the "Look and Feel" is by default Use the same look and feel of the Public Pages."and because of that my custom theme is not applied. How to I set my layout "Look and Feel" to be by default to "Define a specific look and feel for this page."?
I ended up with changing some parameters and is working now:
LayoutLocalServiceUtil.updateLookAndFeel(
layout.getGroupId(),
layout.getPrivateLayout(),
layout.getLayoutId(),
myThemeId,
theme.getColorSchemeId(),
theme.getPathThemeCss()
);
I too faced this issue and able to resolve by passing colorschemeid.
ColorShemeId can be fetched from themelocalserviceutil for a particular theme.
I just passed "01" as default value and there is no error.
ColorShemeId can be fetched from themelocalserviceutil for a particular theme.
I just passed "01" as default value and there is no error.
layoutLocalService.updateLookAndFeel(groupId, privateLayout, layout.getLayoutId(), themeId,
"01", layoutCss);
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™