フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Balaji Chopparapu
How to set attribute in template
2012/09/30 20:04
答え

Balaji Chopparapu

ランク: New Member

投稿: 22

参加年月日: 2010/10/08

最近の投稿

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
Bart Simpson
RE: How to set attribute in template
2012/10/01 0:49
答え

Bart Simpson

ランク: Liferay Master

投稿: 524

参加年月日: 2011/08/29

最近の投稿

I am afraid you won't be able to set anything like this. You'll have to retrieve the preferences and then store them.

1#set ($plid = $getterUtil.getLong($request.get("theme-display").get("plid")))
2#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
3#set ($id = $request.get("theme-display").get("portlet-display").get("id"))
4#set ($portletPreferencesFactoryUtil = $portal.getClass().forName("com.liferay.portlet.PortletPreferencesFactoryUtil"))
5#set ($portletPreferences = $portletPreferencesFactoryUtil.getPortletSetup($layoutLocalService.getLayout($plid),$id,null))
6
7#set ($void = $portletPreferences.setValue("portletSetupTitle_en_US", "Changed"))
8#set ($void = $portletPreferences.store())
Sampsa Sohlman
RE: How to set attribute in template
2012/10/01 3:39
答え

Sampsa Sohlman

LIFERAY STAFF

ランク: Regular Member

投稿: 226

参加年月日: 2007/09/27

最近の投稿

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.