Foren

Embedding a custom portlet in a custom theme

thumbnail
William Gosse, geändert vor 8 Jahren.

Embedding a custom portlet in a custom theme

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Hi, I've some articles on how put a custom portlet in a custom theme out on the web but they seemed a little dated. I was hoping that some one would have some current information on how this can be done.
thumbnail
Olaf Kock, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
It'd be good to know what you already read - the basic technique didn't change a lot, it might still be accurate. Or did you try it and it didn't work?
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Here's two I found:
http://www.liferay.com/community/forums/-/message_boards/message/34749078
https://www.liferay.com/community/forums/-/message_boards/message/16646210
thumbnail
Travis Cory, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Junior Member Beiträge: 73 Beitrittsdatum: 04.06.13 Neueste Beiträge
Hello William,

I'd take a look at the DOM to see what the proper portletID is. I've followed the following pattern

#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($custom_portlet = '[portlet-name]_WAR_[name]')

$theme.runtime($custom_portlet, '', $velocityPortletPreferences.toString())

Where, "portlet-name" is pulled from the custom portlet liferay-portlet.xml, and, "name" is pulled from the name of the portlet. As I said initially inspecting the DOM can be very useful in determining how to import the custom portlet.
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
Ok this is sort of working except for when I change pages it looks like I have two different instances of the same portlet. I wnat one single instance across all pages. I'm using JSF, speicifcally Primefaces, with SessionScope, but I'm not seeing my current values when maintianed when I go from one page to another.
thumbnail
David H Nebinger, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
William Gosse:
I'm using JSF, speicifcally Primefaces, with SessionScope, but I'm not seeing my current values when maintianed when I go from one page to another.


Just because it is session scoped that doesn't mean that changes on the front end will be persisted to the session for you.

Session scope will be updated if you invoke an action on your portlet, not on someone else's.

What I usually do in this case is manage state using AJAX. A change in the browser gets pushed to the back so the session can be updated regardless of what else a user submits on.
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
I am calling ajax actions to to persist my changes. The issue seems to be that that even though its on portlet embedded in theme its actually different instances per page
thumbnail
David H Nebinger, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Yeah, that's likely. Even though it may not be instantiable, different pages would translate into different instances.

Can you persist in the DB perhaps?

Like dockbar, for example, would also be on different pages and likely different instances, but they don't really have any session scoped data it's all based on what's available in the current context.
thumbnail
Travis Cory, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Junior Member Beiträge: 73 Beitrittsdatum: 04.06.13 Neueste Beiträge
Hey William,

If you look at this page it appears you can specify an instance id for the portlet. Give that a shot! Good luck!
thumbnail
William Gosse, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Liferay Master Beiträge: 533 Beitrittsdatum: 04.07.10 Neueste Beiträge
So I did get this working with the following code in my portal_normal.vm:
<div class="moasisaccountheader">
#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($custom_portlet = 'accountssearch_WAR_MoasisAgencyportlet')

$theme.runtime($custom_portlet, '', $velocityPortletPreferences.toString())
</div>
karthik reddy, geändert vor 8 Jahren.

RE: Embedding a custom portlet in a custom theme

Junior Member Beiträge: 60 Beitrittsdatum: 08.04.13 Neueste Beiträge
Hi William,
Hope so your code is working fine just for reference you can check this link Custom portlet in theme