Foren

How to set attribute in template

Balaji Chopparapu, geändert vor 11 Jahren.

How to set attribute in template

New Member Beiträge: 22 Beitrittsdatum: 08.10.10 Neueste Beiträge
Hi,
I am trying to change portlet title in a template but it is not working. Can you please suggest?
This is not working. Portlet title is not changed
$request.get("theme-display").get("portlet-display").set("title","Changed Titile")

But get is working
$request.get("theme-display").get("portlet-display").get("title")

Thanks in Advance
Balaji
thumbnail
Paul ., geändert vor 11 Jahren.

RE: How to set attribute in template

Liferay Master Beiträge: 522 Beitrittsdatum: 29.08.11 Neueste Beiträge
I am afraid you won't be able to set anything like this. You'll have to retrieve the preferences and then store them.

#set ($plid = $getterUtil.getLong($request.get("theme-display").get("plid")))
#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#set ($id = $request.get("theme-display").get("portlet-display").get("id"))
#set ($portletPreferencesFactoryUtil = $portal.getClass().forName("com.liferay.portlet.PortletPreferencesFactoryUtil"))
#set ($portletPreferences = $portletPreferencesFactoryUtil.getPortletSetup($layoutLocalService.getLayout($plid),$id,null))

#set ($void = $portletPreferences.setValue("portletSetupTitle_en_US", "Changed"))
#set ($void = $portletPreferences.store())
thumbnail
Sampsa Sohlman, geändert vor 11 Jahren.

RE: How to set attribute in template

Regular Member Beiträge: 230 Beitrittsdatum: 27.09.07 Neueste Beiträge
Hi,

I'm assuming that this templating questions is for themes.

Balaji Chopparapu:
I am trying to change portlet title in a template but it is not working. Can you please suggest?


If you just want to change portlet name to be displayed at theme do the changes at portlet.vm, where you can decide what is the portlet name on the page.

Paul .:
You'll have to retrieve the preferences and then store them.


Storing the preferences at theme is not good idea, since that causes database traffic and will kill performance of portal.