Fórum

redirect from theme to portlet.

thumbnail
pramod kumara, modificado 6 Anos atrás.

redirect from theme to portlet.

Junior Member Postagens: 54 Data de Entrada: 29/08/16 Postagens Recentes
hello everyone,
Can anyone tell me, How to render from theme to portlet? suppose iam having a button in theme and onclick event of that button should goto view page of the portlet.
How can I achieve this?
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: redirect from theme to portlet.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Pramod,

You would need to create a renderURL that references the portlet and page that you want to target. Which version of the portal are you using? I might be able to provide you an example.
thumbnail
pramod kumara, modificado 6 Anos atrás.

RE: redirect from theme to portlet.

Junior Member Postagens: 54 Data de Entrada: 29/08/16 Postagens Recentes
Liferay 6.2.
please provide me the example
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: redirect from theme to portlet.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Here is what I have done in the past to get this working. Obviously, you need to change the parameters according to your actual values. This is using Freemarker.

NOTE: The false parameter on the second line indicates that the page I am targeting (that has the portlet) is public.

<#assign layoutService = serviceLocator.findService("com.liferay.portal.service.LayoutLocalService")/>
<#assign myCustomLayout = layoutService.getFriendlyURLLayout(group_id, false, '/yourLayoutFriendlURL')/>
<#assign myPortletURL = portletURLFactory.create(request, 'myportletname_WAR_myprojectname', myCustomLayout.getPlid(), 'RENDER_PHASE')/>


Once you have the myPortletURL, you can then add parameters to it or whatever. I do this stuff in my init_custom.ftl and then in, say the portal_normal.ftl, where I want to use it I can reference it like this --

<div>
    <a href="${myPortletURL}">Link to Portlet</a>
</div>


HTH.