We have several sites hosted on an instance of Liferay 5.2, consisting of several communities, themes and layout templates, everything works as expected. However, this setting no longer works in EE version 5.2 service packs (in particular, the latest EE SP5 is the same as in version 5.2.9) or the latest 6.0.6 (CE). (Additional testing showed that it worked recently in EE SP3 / 5.2.7, but became a problem in EE SP4 / 5.2.8.) We urgently need to upgrade to the latest service pack 5.2 (EE SP5) to solve other problems - but upgrade to Liferay 6 is also an option if we can find a combination of solution and version that works.
In particular, we have files in the theme (for example, inc-side.vm ) that are included as part of the theme and are included in layout templates. This allows the content to “own” the theme, but is used in the context of different layout templates - although the same layout templates are used on several sites (communities / themes). Placing this content directly in the theme (without involving a layout template) is not an option, since it needs to be placed in the layout UI space, and different layouts may require that this content be in different places relative to the theme.
An additional requirement is that this included content should consist of "embedded" portlets - IE, not dragged into the user interface on the page, but associated with each theme / layout. By simply applying the theme + layout to the site / page, the correct portlets are automatically included on each page. This is necessary because with some sites / communities consisting of about 100 or more pages, adding this content to the page and maintaining its integrity without introducing the theme + into the layout would not be practical and not repairable. (Consider only 10 (community) topics * 10 layout templates * 10 pages / community = 1000 combinations for customization and support.)
Again, all this worked in accordance with 5.2.3 (including 5.2 EE SP1, SP2 and SP3), but stopped working with 5.2 EE SP4. We are a Liferay support customer, and we have a support ticket for almost 2 months without permission on this issue. The release notes did not mention anything, and we have not yet received any recommendations from Liferay about why this has changed or any successful workarounds.
Here are some features of the current problem:
Easy and consistent to play with any new installation of 5.2 EE SP4 or SP5.
Include inc-side.vm in the templates directory in the theme. There is nothing special about this topic - even when using a copy of Liferay, the default theme will be classic.
In inc-side.vm include the following:
<p>Before Diagnostics</p> $theme.runtime("27_INSTANCE_0000", "", $velocityPortletPreferences.toString()) $velocityPortletPreferences.reset() <p>After Diagnostics</p>
Note that “27” is the default portlet provided by Liferay, which is used for simplicity and demonstrates that this problem does not apply to any specially designed portlet. However, I also created my own “diagnostic portlet” from scratch, which demonstrates exactly the same problem.
In the layout template (* .tpl), specify the following lines:
#set ($contextName = $themeDisplay.getTheme().getContextPath())
This follows the same approach shown at http://www.liferay.com/community/forums/-/message_boards/message/772138 .
At the suggestion of our support ticket, I also tried the following 1-line alternative to the above lines:
#parse ("$fullTemplatesPath/inc-side.vm")
(Note $fullTemplatesPath vs. $full_templates_path . The reason for this is that init.vm calls #set ($full_templates_path = $fullTemplatesPath) - but init.vm not included in the templates, but just a theme.)
The results for both approaches are identical. Any static text / HTML contained in inc-side.vm is rendered as expected. Any Velocity directives are parsed and processed and are not displayed at the output. Entering the portlet shows that it has completed and even receives any portlet settings that were set to velocityPortletPreferences . The root problem is that any content created by the portlet is not sent in an HTTP response. In fact, if you look in Firefox "View / Source" or cURL, the answer contains exactly:
<p>Before Diagnostics</p> <p>After Diagnostics</p>
In my custom portlet, I even tried to call every flush() and close() method that I could find in the answer, believing that this was a flushing issue.
Testing under Liferay 6.0.6 instead (assuming that this was only a 5.2 series issue) yields different, but interesting results. The included * .vm file is successfully read on the page. However, it is not evaluated as a speed code. Unlike 5.2 SP5, which runs an included VM, but just does not render, 6.0.6 does the rendering, but does not evaluate (or does).
We looked at http://www.liferay.com/web/raymond.auge/blog/-/blogs/11180056 ("Embedding Portlets in Liferay Themes"), and the above approach is truly a "one-way" approach. "Method two" is not an acceptable option, since using an <iframe> causes problems with the DOM of the page (in particular, using JavaScript IPC) - and this also requires that the size of the user interface of each portlet be known in advance, which is not practical or acceptable.
We hope that someone more familiar with Liferay and / or the Apache Velocity template engine (used by Liferay) can provide a solution or other acceptable solution to this problem. I will provide any additional details or clarifications that I can make.
Thanks!