Fórum

language portlet in theme for site template based pages...

thumbnail
Alain Dresse, modificado 11 Anos atrás.

language portlet in theme for site template based pages...

Junior Member Postagens: 95 Data de Entrada: 18/07/11 Postagens Recentes
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
$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:
if (publicSiteTemplateId != 0){
	LayoutSetPrototype prototype = LayoutSetPrototypeLocalServiceUtil
			.getLayoutSetPrototype(publicSiteTemplateId);
	LayoutSetLocalServiceUtil.updateLayoutSetPrototypeLinkEnabled(
			groupId, 
			false,  //privateLayout, 
			true,   //layoutSetPrototypeLinkEnabled
			prototype.getUuid()
			);
}


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
    <liferay-ui:language displayStyle="<%= LanguageTag.LIST_ICON %>" languageIds="<%= languageIds %>" />

    does not work.


workaround
Embed the language portlet in the theme using $theme.runtime:
$velocityPortletPreferences.setValue("portletSetupShowBorders","false")
<menu class="nav-horizontal" id="language-navigation">
	<ul>
		<li>$theme.runtime("82", "", $velocityPortletPreferences.toString())</li>
	</ul>
</menu>
$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
thumbnail
Alain Dresse, modificado 11 Anos atrás.

RE: language portlet in theme for site template based pages...

Junior Member Postagens: 95 Data de Entrada: 18/07/11 Postagens Recentes
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.
		DynamicQuery query = PortletPreferencesLocalServiceUtil.dynamicQuery();
		query.add(RestrictionsFactoryUtil.eq("portletId", languageLayoutPortletId));
		@SuppressWarnings("unchecked")
		List<portletpreferences> preferenceList = PortletPreferencesLocalServiceUtil.dynamicQuery(query);
		
		for (PortletPreferences preferences : preferenceList){
			Layout layout = LayoutLocalServiceUtil.getLayout(preferences.getPlid());
			javax.portlet.PortletPreferences javaPrefs = PortletPreferencesFactoryUtil.getPortletSetup(layout, languageLayoutPortletId, StringPool.BLANK);
			String showBorders = javaPrefs.getValue("portletSetupShowBorders", StringPool.TRUE);
			if (!showBorders.equals(StringPool.FALSE)) {
				javaPrefs.setValue("portletSetupShowBorders", StringPool.FALSE);
				javaPrefs.store();
			}
		}
	
	private static String languageLayoutPortletId = "82";</portletpreferences>


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
thumbnail
Rewati Raman, modificado 11 Anos atrás.

RE: language portlet in theme for site template based pages...

Junior Member Postagens: 97 Data de Entrada: 24/02/12 Postagens Recentes
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