Foren

Embedding Language Portlet into custom theme

Jatinderpal Singh, geändert vor 8 Jahren.

Embedding Language Portlet into custom theme

Junior Member Beiträge: 49 Beitrittsdatum: 14.08.15 Neueste Beiträge
I am trying to embed Language Portlet into my custom theme. I am using the following code : -
#set ($VOID = $velocityPortletPreferences.setValue('display-style', '1'))
#set ($VOID = $velocityPortletPreferences.setValue('portlet-setup-show-borders', 'false'))
#set ($instanceId = 'E8j2')
#set ($myPortletId = "82_INSTANCE_${instanceId}")$theme.runtime($myPortletId, '', $velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())


It embeds well. But it does not work. It does not convert the language of the page. It just reloads the page.
How it can be embedded into theme?
Jatinderpal Singh, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme

Junior Member Beiträge: 49 Beitrittsdatum: 14.08.15 Neueste Beiträge
Is there any other solution ? Kindly suggest. I urgently need this
thumbnail
Bijan Vakili, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme

Expert Beiträge: 375 Beitrittsdatum: 10.03.09 Neueste Beiträge
Line 4 in code's actually two lines. In any case, here is what I think:
That portlet is just not instanceable:

        <portlet>
                <portlet-name>82</portlet-name>
                <icon>/html/icons/language.png</icon>
                <struts-path>language</struts-path>
                <configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>
                <preferences-owned-by-group>true</preferences-owned-by-group>
                <use-default-template>false</use-default-template>
                <layout-cacheable>true</layout-cacheable>
                <private-request-attributes>false</private-request-attributes>
                <private-session-attributes>false</private-session-attributes>
                <render-weight>50</render-weight>
                <css-class-wrapper>portlet-language</css-class-wrapper>
                <add-default-resource>true</add-default-resource>
        </portlet>


https://github.com/liferay/liferay-portal/blob/6.2.x/portal-web/docroot/WEB-INF/liferay-portlet.xml#L753
Have you tried configuring it for site?
Jatinderpal Singh, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme

Junior Member Beiträge: 49 Beitrittsdatum: 14.08.15 Neueste Beiträge
Thank you dear for pointing out about instancable of the portlet.
I am just new to all these things.
I googled about it and tried this method : -
https://www.liferay.com/web/raymond.auge/blog/-/blogs/embedding-portlets-in-themes-on-liferay#ofge_message_64576913

It does the same thing. It embeds well the portlet. On change of the language, it refreshes the page and restore the selected value. But does not translate the page.
Then I have to reload the page and then it translate the page.
Can we improve it ?
Jatinderpal Singh, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme (Antwort)

Junior Member Beiträge: 49 Beitrittsdatum: 14.08.15 Neueste Beiträge
Okay.
I am able to find a working way to add language portlet to theme by following method : -
$theme.langauge()


But now the next step is to find out how to configure this portlet's from ICONS to SELECT BOX.
Is there any way to do so ?
thumbnail
Bijan Vakili, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme

Expert Beiträge: 375 Beitrittsdatum: 10.03.09 Neueste Beiträge
You can create JSP hook for that; to override or extend JSP; e.g. to hide icons and add drop down.

There are lots of resources on the hooks; see the Liferay dev guide or just search this:
https://www.google.com/search?client=ubuntu&channel=fs&q=liferay+jsp+hook&ie=utf-8&oe=utf-8
Jatinderpal Singh, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme

Junior Member Beiträge: 49 Beitrittsdatum: 14.08.15 Neueste Beiträge
Bijan Thank you for your help.

I have no idea how to hook Liferay Function. I was able to hook only JSP pages.
In my template I am using Liferay Function to embed language portlet into theme.

But I have solved my problem. I changed the images of flags with images containing name of the language.

If is there anything I can do, kindly guide me.
thumbnail
Ramanjeneyulu Bodepudi, geändert vor 8 Jahren.

RE: Embedding Language Portlet into custom theme

Junior Member Beiträge: 42 Beitrittsdatum: 24.02.12 Neueste Beiträge
Need to use theme.runtime with corresponding portlet id for including portlet in theme,