Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
maryam maryam masoudy
how can i change portlet title in velocity template?
October 30, 2012 2:11 AM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

hi
i want to set portlet title in velocity template
i work with liferay6.1
i wrote this code but portlet title didnot change
1
2#set ($myPortletId = "56_INSTANCE_Xmi4S46xzzfL")
3$velocityPortletPreferences.setValue("custom-title", "bbbbbbbbb")
4$velocityPortletPreferences.setValue("title", "kkkkkkkk")
5$velocityPortletPreferences.setValue("portlet-title", "cccccccc")
6$theme.runtime($myPortletId, '', $velocityPortletPreferences.toString())
7#set ($VOID = $velocityPortletPreferences.reset())


in portlet option >advance, styling portlet id is : Portlet ID: #portlet_56_INSTANCE_Xmi4S46xzzfL
i use 56_INSTANCE_Xmi4S46xzzfL it is corect?
is my velocity corect?
how can i change portlet title in velocity template?
thanks
Pavel Savinov
RE: how can i change portlet title in velocity template?
October 30, 2012 2:16 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Hi Maryam.

Try $portletDisplay.setTitle("yourTitleHere");
maryam maryam masoudy
RE: how can i change portlet title in velocity template?
October 30, 2012 2:51 AM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

i wrote $portletDisplay.setTitle("yourTitleHere") but in content
shown $portletDisplay.setTitle("yourTitleHere") without any result and my title didnot change
do i write $portletDisplay.setTitle("yourTitleHere") only without anything?
thanks
Pavel Savinov
RE: how can i change portlet title in velocity template?
October 30, 2012 4:10 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

I've checked it. Unfortunatelly $portletDisplay object is not available in the CMS content templates emoticon
I'll try to find out some other method.
maryam maryam masoudy
RE: how can i change portlet title in velocity template?
October 30, 2012 4:24 AM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

ohhh thanks Pavel
but i donot knew what do i do emoticon
Nikhil Nishchal
RE: how can i change portlet title in velocity template?
October 30, 2012 4:35 AM
Answer

Nikhil Nishchal

Rank: Junior Member

Posts: 74

Join Date: June 21, 2012

Recent Posts

Pavel Savinov:
I've checked it. Unfortunatelly $portletDisplay object is not available in the CMS content templates emoticon
I'll try to find out some other method.


$portletDisplay object can be get through
$request.get("theme-display").get("portlet-display")

Or
$request.theme-display.portlet-display
maryam maryam masoudy
RE: how can i change portlet title in velocity template?
October 30, 2012 4:48 AM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

Hi Nikhil Nishchal thanks for reply
i could get portlet title but now how do i set my title? emoticon
Pavel Savinov
RE: how can i change portlet title in velocity template?
October 30, 2012 4:53 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Maryam, Liferay hack for you emoticon

Put following code into your template text, replace newTitle var value with desired title.

 1<script>
 2function updatePortletTitle(children,title) {
 3    if (children!=null && children.length>0) {
 4        for (var k=0;k<children.length;k++) {
 5            if (children[k].className == 'portlet-title-text') {
 6                children[k].innerHTML = title;
 7                break;
 8            }
 9            if (children[k].childNodes != null &&
10                children[k].childNodes.length > 0) {
11                updatePortletTitle(children[k].childNodes,title);   
12            }
13        }
14    }
15}
16
17var portletId = "portlet_$request.theme-display.portlet-display.id";
18var portletSection = document.getElementById(portletId);
19var newTitle = "Test Dynamic Title";
20
21updatePortletTitle(portletSection.childNodes,newTitle);
22</script>


It works fine on 6.1.1 CE emoticon
maryam maryam masoudy
RE: how can i change portlet title in velocity template?
October 30, 2012 4:55 AM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

thanks Pavel
i write this code in velocity template?
Pavel Savinov
RE: how can i change portlet title in velocity template?
October 30, 2012 4:56 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

maryam maryam masoudy:
thanks Pavel
i write this code in velocity template?


Yes, in the template text.
maryam maryam masoudy
RE: how can i change portlet title in velocity template?
October 30, 2012 4:59 AM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Pavel it is correct thanks veryyyyyyyyyyyyyyyyyyyyyyyy much emoticon
Alireza Zare
RE: how can i change portlet title in velocity template?
October 30, 2012 7:50 AM
Answer

Alireza Zare

Rank: Regular Member

Posts: 110

Join Date: September 3, 2010

Recent Posts

The short version:
<script>
AUI().ready(function(A) {
var portletContainer= A.one("#portlet_$request.theme-display.portlet-display.id");
var portletTitle= portletContainer.one(".portlet-title-text");
portletTitle.setContent("News");

});
</script>
maryam maryam masoudy
RE: how can i change portlet title in velocity template?
October 30, 2012 10:39 PM
Answer

maryam maryam masoudy

Rank: Regular Member

Posts: 149

Join Date: October 30, 2011

Recent Posts

thanks for reply