Forums de discussion

[Custom Hook ]-Update Look and Feel

piovono polpette, modifié il y a 14 années.

[Custom Hook ]-Update Look and Feel

Junior Member Publications: 49 Date d'inscription: 01/10/09 Publications récentes
Hi to all,
I have a problem of updating look and feel of organization pages created with custom hook.
Each organization has 3 pages and I want that each one has a different theme.
With the following line I set a theme for all pages and works correctly:


LayoutSetLocalServiceUtil.updateLookAndFeel(group.getGroupId(), false, "minisite_1theme", "", "", false);


But if I want to update look and feel of each page with the following instruction, it doesn't work:


LayoutLocalServiceUtil.updateLookAndFeel(group.getGroupId(), false, layout.getLayoutId(),
                "minisite_2theme", "", "", false);


Any syggestions for my problem?
Thanks in advance for your help!
thumbnail
Wesley Reisz, modifié il y a 13 années.

RE: [Custom Hook ]-Update Look and Feel

New Member Publications: 2 Date d'inscription: 19/11/10 Publications récentes
I realize this post is over 1 year old, but I was looking for the answer today to this exact question, and ended up tracking down the reason behind this behavior. So I thought I'd post the answer.

The Layout.isInheritLookAndFeel() getter looks like this:


public boolean isInheritLookAndFeel() {
    if (Validator.isNull(getThemeId()) ||
        Validator.isNull(getColorSchemeId())) {
		return true;		
    }else { return false; }
}

In order for the Layout to use it's own defined theme, both the ThemeId and ColorSchemeId have to be set. This means that when you call LayoutLocalServiceUtil.updateLookAndFeel() like this:


LayoutLocalServiceUtil.updateLookAndFeel(group.getGroupId(), false, layout.getLayoutId(), "minisite_2theme", "", "", false);

You're not setting a ColorSchemeId, and so when the getTheme() for the Layout is called, it gets a true back from isInheritLookAndFeel, so will send back the group's defined Theme instead of its own.

You can set a single page by using the following call:


LayoutLocalServiceUtil.updateLookAndFeel(group.getGroupId(), false, layout.getLayoutId(), "minisite_2theme", "01", "", false);

This works, as the default ColorSchemeId for a Theme seems to be "01".