Foren

$taglibLiferay.runtime help

Daniel Lipski, geändert vor 13 Jahren.

$taglibLiferay.runtime help

New Member Beiträge: 3 Beitrittsdatum: 13.04.11 Neueste Beiträge
Hi,

Im new Liferay user/developer so please foregive me if I misunderstood something.

What Im trying to do is to develop custom theme and "include" custom portled inside velocity template.

1)I devloped simple helo-world portlet and deployed it to Liferay.
project_name:MyPortlet-portlet
portlet_id:MyPortlet
deploment type: plugin (subfolder in tomcat webapps)

2)I developed simple theme and override one of velocity templates (portal_normal.vm).
In the template I added few lines of velcity code:
#set ($VOID = $velocityPortletPreferences.setValue('display-style', '1'))
#set ($VOID = $velocityPortletPreferences.setValue('portlet-setup-show-borders', 'false'))
#set ($myPortletId = "[b]MyPortlet_INSTANCE_E3j7_WAR_MyPortlet-portlet[/b]")
$taglibLiferay.runtime($myPortletId, '', $velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())


3)When I deploy this theme and refresh page nothing is displayed in place of this "inclusion". When I add my portlet with page->add->... Hello world appears.

I debug Liferay for a whole day and probably found a cause.

Its in the RuntimePortletUtil.processPortlet(...) method:

String instanceId = portlet.getInstanceId();


For my template this instanceId = "E3j7_WAR_MyPortlet-portlet"
As I suspect the correct version should be only "E3j7".

Thats why few lines of code below validation fails (id length != 4) and "Portlet is instanceable but does not have a valid instance id" is displayed.

Ive tried with difrrent portledId passed to $taglibLiferay.runtime but nothing work.
Regarding to this wiki page my Id should work:wiki

Do I do something wrong ? What is a difference beetween $taglibLiferay.runtime and $theme.runtime ??

Reagrds Daniel
thumbnail
Eduardo P. García, geändert vor 3 Jahren.

RE: $taglibLiferay.runtime help

Regular Member Beiträge: 157 Beitrittsdatum: 16.03.12 Neueste Beiträge
Hi Daniel,

This is what you are doing wrong:


...
#set ($myPortletId = "[b]MyPortlet_INSTANCE_E3j7_WAR_MyPortlet-portlet[/b]")
...


Your portletId should be:


...
#set ($myPortletId = "[b]MyPortlet_WAR_MyPortlet-portlet_INSTANCE_E3j7[/b]")
...


In other words, the right scheme is:

<portletId>_WAR_<webapplicationcontext>[_INSTANCE_xyz1]

where [...] is only for instanceable portlets.

As for the differences between $taglibLiferay.runtime and $theme.runtime, if you are using Liferay 6.0 or above, you must use $theme.runtime instead of $taglibLiferay.runtime to embed portlet.

For more information, you can visit this Wiki: Embedding a portlet in a Theme

Regards
richard naoufal, geändert vor 10 Jahren.

RE: $taglibLiferay.runtime help

Junior Member Beiträge: 34 Beitrittsdatum: 04.04.13 Neueste Beiträge
Hello,

Is it possible to change the language of a page by adding a language portlet, changing the preferences and choosing a language this way ?

Thank you !