Skip to content

Instantly share code, notes, and snippets.

@randombrad
Created December 6, 2011 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save randombrad/1439215 to your computer and use it in GitHub Desktop.
Save randombrad/1439215 to your computer and use it in GitHub Desktop.
Embeded Web Form Portlet into theme
#set ($locPortletId = "1_WAR_webformportlet_INSTANCE_dfer")
#set ($portletPreferencesFactoryUtil = $portal.getClass().forName("com.liferay.portlet.PortletPreferencesFactoryUtil"))
#set ($portletSetup = $portletPreferencesFactoryUtil.getLayoutPortletSetup($layout, $locPortletId))
#set ($temp = $portletSetup.setValue("portletSetupShowBorders", "true"))
#set ($temp = $portletSetup.setValue("title", "Sign up for SEVENCOGS updates!"))
#set ($temp = $portletSetup.setValue("description", " "))
#set ($temp = $portletSetup.setValue("subject", "Subscription"))
#set ($temp = $portletSetup.setValue("saveToDatabase", "true"))
#set ($temp = $portletSetup.setValue("fieldLabel1", ""))
#set ($temp = $portletSetup.setValue("field1Value", "Email"))
#set ($temp = $portletSetup.setValue("fieldType1", "text"))
#set ($temp = $portletSetup.setValue("fieldLabel2", ""))
#set ($temp = $portletSetup.setValue("fieldType2", ""))
#set ($temp = $portletSetup.store())
##
## Create the portletURL
##
$theme_display.isWidget()
#set ($widget = $theme_display.isWidget())
#set ($VOID = $theme_display.setWidget(true))
$theme_display.isWidget()
#set ($embeddedPortletURL = $portletURLFactory.create($request, $locPortletId, $page.plid, "RENDER_PHASE"))
##set ($embeddedPortletURL = $portletURLFactory.create($request, $locPortletId, $layout.plid, "RENDER_PHASE"))
## Make sure it's in popup mode, otherwise it doesn't embed nicely.
#set ($VOID = $embeddedPortletURL.setWindowState("normal"))
#set ($VOID = $embeddedPortletURL.setPortletMode("view"))
## You can set parameters if you like
#set ($VOID = $embeddedPortletURL.setParameter("field1", "Email"))
#set ($widget = $theme_display.setWidget($widget))
$theme_display.isWidget()
${embeddedPortletURL.toString()}
## The iframe. You'll have to set the width of the iframe.
<iframe frameborder="0" id="${locPortletId}" src="${embeddedPortletURL}" scrolling="no" height="100%" width="100%"></iframe>
## This is the nifty plugin that will proportion the iframe automatically with the height of the content.
## This only works if the portlet is in the same domain as the portal of course.
<script type="text/javascript">
AUI().use('aui-resize-iframe','aui-node', function(A) {
A.one('#${locPortletId}').plug(A.Plugin.ResizeIframe);
});
</script>
@JideLambo
Copy link

Hello randombrad, Im having a bit of an issue with embedding a web form in my portal_normal.vm using liferay 6.

Ive tried out your solution here but it seem not to work. Can you be kind enough to let me know what works on liferay 6? Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment