Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
LOUIS Nicolas
How to open a portlet in a new popup
October 20, 2010 8:11 AM
Answer

LOUIS Nicolas

Rank: New Member

Posts: 5

Join Date: July 22, 2010

Recent Posts

Hello,

I need some help to find a better solution for my problem! I find a working version, but i think it's not correct.
I want to show a portlet in a jQuery popup !

So i created a link in the dock.vm to open the popup on the different page of my website like this :
 1
 2<a href="javascript:showPopup('13309', 'PopupViewPortlet_WAR_projectportlet')">Open the popup</a>
 3<script type="text/javascript">
 4function showPopup(plid, ppid) {
 5    var instance = this;
 6    // var plid = themeDisplay.getPlid();
 7    if (!instance.menu) {
 8        instance.menu = true;
 9        var url = themeDisplay.getPathMain() + '/portal/render_portlet';
10        instance._dialog = Liferay.Popup( {
11            title : 'Popup Title',
12            width : 310,
13            height : 'auto',
14            modal : true,
15            resizable : false,
16            message : '<div class="loading-animation" />',
17            onClose : function() {
18                instance.menu = null;
19            }
20        });
21        jQuery.ajax( {
22            url : url,
23            data : {
24                p_l_id : plid,
25                p_p_id : ppid,
26                p_p_state : 'exclusive'
27            },
28            success : function(message) {
29                instance._dialog.html(message);
30            }
31        });
32    }
33}
34</script>


This link open my popup correctly but i have to define the p_l_id, otherwise, it's not working.
To define a p_l_id, i put my portlet in a hidden page to get the p_l_id, and it's working, but this number could change in the future...i can't put a number like this ! And if i put the current p_l_id, the portlet doesn't show.

Do you understand my problem ?

Thanks for your help, and sorry for my bad english ! emoticon

Nicolas.
Peter Shin
RE: How to open a portlet in a new popup
October 20, 2010 9:26 AM
Answer

Peter Shin

LIFERAY STAFF

Rank: Regular Member

Posts: 122

Join Date: September 24, 2007

Recent Posts

Hi Louis, here's one way to dynamically get the plid

1<%= PortalUtil.getPlidFromPortletId(themeDisplay.getParentGroupId(), "PopupViewPortlet_WAR_projectportlet") %>
LOUIS Nicolas
RE: How to open a portlet in a new popup
October 21, 2010 2:36 AM
Answer

LOUIS Nicolas

Rank: New Member

Posts: 5

Join Date: July 22, 2010

Recent Posts

Thanks ! It's working :-)

I use this command :

1
2#set ($plid_popup = $portalUtil.getPlidFromPortletId($portalUtil.getScopeGroupId($request), "PopupViewPortlet_WAR_projectportlet"))


I would like to know if i have to put this portlet in a hidden page ? How can i delete this portlet keeping the same behavior ?

Thanks,

Nicolas.
Peter Shin
RE: How to open a portlet in a new popup
October 21, 2010 12:59 PM
Answer

Peter Shin

LIFERAY STAFF

Rank: Regular Member

Posts: 122

Join Date: September 24, 2007

Recent Posts

The portlet can be on any page in the current community/organization.

If the portlet isn't found it'll return 0 and in that case it'd probably be better to hide the link.
Jelmer Kuperus
RE: How to open a portlet in a new popup
October 22, 2010 1:14 AM
Answer

Jelmer Kuperus

Rank: Liferay Legend

Posts: 1192

Join Date: March 10, 2010

Recent Posts

What I do is this :

In liferay-portlet.xml configure the popup portlet like this :

1<portlet>
2    <portlet-name>yourportletid</portlet-name>
3    <add-default-resource>true</add-default-resource>
4</portlet>



Then construct a url like this and load it in the popup

1PortletURL url = PortletURLFactoryUtil.create(request, "yourportletid_WAR_yourwarname",
2        layout.getPlid(), PortletRequest.RENDER_PHASE);
3url.setWindowState(LiferayWindowState.EXCLUSIVE);


In some cases you also needed to add the portletId to the portlet.add.default.resource.check.whitelist property, but i dont quite remember what the criteria was for that
santhosh kumar
RE: How to open a portlet in a new popup
December 27, 2012 4:49 AM
Answer

santhosh kumar

Rank: New Member

Posts: 19

Join Date: April 10, 2011

Recent Posts

Hi

On click of link i'm triggering below mentioned code but on load of page its throeing JS error "Expected ';' "

function parentPage() {
alert("hi");
PortletURL url = PortletURLFactoryUtil.create(request,"PLDoc_WAR_PLDocportlet",layout.getPlid(),PortletRequest.RENDER_PHASE);
url.setWindowState(LiferayWindowState.EXCLUSIVE);
var popup = Liferay.Popup(
{
stack: true,
draggable:false,
title: 'Parent Page',
position:[110,50],
modal:true,
width:450,
height:365,
url:url
}
);
}