Foros de discusión

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

thumbnail
Alain Dresse, modificado hace 11 años.

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

Junior Member Mensajes: 95 Fecha de incorporación: 18/07/11 Mensajes recientes
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 hace 11 años.

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

Junior Member Mensajes: 95 Fecha de incorporación: 18/07/11 Mensajes recientes
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 hace 11 años.

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

Junior Member Mensajes: 97 Fecha de incorporación: 24/02/12 Mensajes recientes
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