Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Alain Dresse
language portlet in theme for site template based pages...
January 7, 2013 8:59 AM
Answer

Alain Dresse

Rank: Junior Member

Posts: 95

Join Date: July 18, 2011

Recent Posts

Hi all,

I have been facing a wierd issue for the last hours, have a workaround, but don't quite understand what's going on. I hope my post will help people that could have similar issues, and maybe that a liferay guru can shed some light on the crix of the issue.

Issue
The language portlet, embedded in my theme using
1$theme.language()

works fine for most pages on my portal.
It doesn't work for pages created from page templates...

The pages are created from site templates using the following code:
 1if (publicSiteTemplateId != 0){
 2    LayoutSetPrototype prototype = LayoutSetPrototypeLocalServiceUtil
 3            .getLayoutSetPrototype(publicSiteTemplateId);
 4    LayoutSetLocalServiceUtil.updateLayoutSetPrototypeLinkEnabled(
 5            groupId,
 6            false,  //privateLayout,
 7            true,   //layoutSetPrototypeLinkEnabled
 8            prototype.getUuid()
 9            );
10}


observations
  • The language portlet embedded in the theme works for an omniadmin user, but not for a standard (or guest) user.
  • The language portlet added on a page works.
  • The language selector added to any other portlet using
    1<liferay-ui:language displayStyle="<%= LanguageTag.LIST_ICON %>" languageIds="<%= languageIds %>" />

    does not work.


workaround
Embed the language portlet in the theme using $theme.runtime:
1$velocityPortletPreferences.setValue("portletSetupShowBorders","false")
2<menu class="nav-horizontal" id="language-navigation">
3    <ul>
4        <li>$theme.runtime("82", "", $velocityPortletPreferences.toString())</li>
5    </ul>
6</menu>
7$velocityPortletPreferences.reset()


As I said earlier, I hope this helps someone someday, and I would be more than happy to understand why this workaround is needed. I assume it has to do with generating the actual pages from the page templates.

Best regards,
Alain
Alain Dresse
RE: language portlet in theme for site template based pages...
January 8, 2013 2:11 AM
Answer

Alain Dresse

Rank: Junior Member

Posts: 95

Join Date: July 18, 2011

Recent Posts

Some more information:

Some of my pages already had a language portlet created from the previous version of my theme. To remove the borders, I ran the following code.
 1        DynamicQuery query = PortletPreferencesLocalServiceUtil.dynamicQuery();
 2        query.add(RestrictionsFactoryUtil.eq("portletId", languageLayoutPortletId));
 3        @SuppressWarnings("unchecked")
 4        List<PortletPreferences> preferenceList = PortletPreferencesLocalServiceUtil.dynamicQuery(query);
 5       
 6        for (PortletPreferences preferences : preferenceList){
 7            Layout layout = LayoutLocalServiceUtil.getLayout(preferences.getPlid());
 8            javax.portlet.PortletPreferences javaPrefs = PortletPreferencesFactoryUtil.getPortletSetup(layout, languageLayoutPortletId, StringPool.BLANK);
 9            String showBorders = javaPrefs.getValue("portletSetupShowBorders", StringPool.TRUE);
10            if (!showBorders.equals(StringPool.FALSE)) {
11                javaPrefs.setValue("portletSetupShowBorders", StringPool.FALSE);
12                javaPrefs.store();
13            }
14        }
15   
16    private static String languageLayoutPortletId = "82";


I had also forgotten to note in the previous post that once the admin had gone to a page and changed languages, the page worked for non admin users.

Alain
Rewati Raman
RE: language portlet in theme for site template based pages...
February 15, 2013 4:05 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

Hi Alain,

i am facing issues with Language Portlet customization.
I want borderless language portlet in search box mode

i want this things happen while adding my portlet in theme so that no need to customize from portal

Thanks in advance

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!