Foren

How to open a portlet in a new popup

LOUIS Nicolas, geändert vor 13 Jahren.

How to open a portlet in a new popup

New Member Beiträge: 5 Beitrittsdatum: 22.07.10 Neueste Beiträge
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 :

<a href="javascript:showPopup('13309', 'PopupViewPortlet_WAR_projectportlet')">Open the popup</a>
<script type="text/javascript"> 
function showPopup(plid, ppid) {
	var instance = this;
	// var plid = themeDisplay.getPlid();
	if (!instance.menu) {
		instance.menu = true;
		var url = themeDisplay.getPathMain() + '/portal/render_portlet';
		instance._dialog = Liferay.Popup( {
			title : 'Popup Title',
			width : 310,
			height : 'auto',
			modal : true,
			resizable : false,
			message : '<div class="loading-animation" />',
			onClose : function() {
				instance.menu = null;
			}
		});
		jQuery.ajax( {
			url : url,
			data : {
				p_l_id : plid,
				p_p_id : ppid,
				p_p_state : 'exclusive'
			},
			success : function(message) {
				instance._dialog.html(message);
			}
		});
	}
}
</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.
thumbnail
Peter Shin, geändert vor 13 Jahren.

RE: How to open a portlet in a new popup

Regular Member Beiträge: 121 Beitrittsdatum: 24.09.07 Neueste Beiträge
Hi Louis, here's one way to dynamically get the plid

&lt;%= PortalUtil.getPlidFromPortletId(themeDisplay.getParentGroupId(), "PopupViewPortlet_WAR_projectportlet") %&gt;
LOUIS Nicolas, geändert vor 13 Jahren.

RE: How to open a portlet in a new popup

New Member Beiträge: 5 Beitrittsdatum: 22.07.10 Neueste Beiträge
Thanks ! It's working :-)

I use this command :


#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.
thumbnail
Peter Shin, geändert vor 13 Jahren.

RE: How to open a portlet in a new popup

Regular Member Beiträge: 121 Beitrittsdatum: 24.09.07 Neueste Beiträge
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.
thumbnail
jelmer kuperus, geändert vor 13 Jahren.

RE: How to open a portlet in a new popup

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
What I do is this :

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

<portlet>
	<portlet-name>yourportletid</portlet-name>
	<add-default-resource>true</add-default-resource>
</portlet>



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

PortletURL url = PortletURLFactoryUtil.create(request, "yourportletid_WAR_yourwarname",
		layout.getPlid(), PortletRequest.RENDER_PHASE);
url.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, geändert vor 11 Jahren.

RE: How to open a portlet in a new popup

New Member Beiträge: 19 Beitrittsdatum: 11.04.11 Neueste Beiträge
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
}
);
}