Created
October 21, 2011 18:13
-
-
Save rotty3000/1304533 to your computer and use it in GitHub Desktop.
Embedding a portlet into the theme, the best way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <add-default-resource>true</add-default-resource> | |
| <system>true</system> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #set ($locPortletId = "82") | |
| ## | |
| ## Portlet Setup | |
| ## | |
| ## This is for look and feel only. In case of instanceable portlets this | |
| ## is the same as the PortletPreferences. | |
| ## | |
| ## If you want the PortletPreferences for a non-instancable portlet, | |
| ## you'll have to make a different call. | |
| ## | |
| #set ($portletPreferencesFactoryUtil = $portal.getClass().forName("com.liferay.portlet.PortletPreferencesFactoryUtil")) | |
| #set ($portletSetup = $portletPreferencesFactoryUtil.getLayoutPortletSetup($layout, $locPortletId)) | |
| #if ($portletSetup.getValue("portletSetupShowBorders", "") != "false") | |
| #set ($temp = $portletSetup.setValue("portletSetupShowBorders", "false")) | |
| #set ($temp = $portletSetup.store()) | |
| #end | |
| ## | |
| ## Create the portletURL | |
| ## | |
| #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("pop_up")) | |
| #set ($VOID = $embeddedPortletURL.setPortletMode("view")) | |
| ## You can set parameters if you like | |
| ##set ($VOID = $embeddedPortletURL.setParameter("some_parameter", "some_value")) | |
| ## The iframe. You'll have to set the width of the iframe. | |
| <iframe frameborder="0" id="${locPortletId}custom_frame" src="${embeddedPortletURL.toString()}" scrolling="no" width="50%"></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', function(A) { | |
| A.one('#${locPortletId}custom_frame').plug(A.Plugin.ResizeIframe); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment