liferayliferay-6liferay-7liferay-theme

liferay - how to render one portlet in another portlet


New to Liferay.

Not sure if it's the right approach, but..

I have a page that renders a portlet. And in this portlet I need to render another portlet conditionally (based on a flag stored in the database).

I can retrieve this flag from the database in my portlet but how to render another portlet in the jsp view file is what I'm trying to understand.

So far I've found a liferay tag called portlet:renderURL that might achieve this, but the documentation and other articles I've read are super unclear as to what this tag is supposed to do and how it's supposed to do it? Am I in the wrong direction here?


Solution

  • As Daniele mentioned in a comment (but only by linking to an external article), you're rather looking for the <liferay-portlet:runtime> tag.

    You mention "renderURL", which only results in a URL that would render the whole page including the portlet. I understand that you're looking at the content of just a single portlet to be rendered.

    That tag should give you enough starting point to go for it: If you don't need to configure it with preferences, it's quite simple to use.

    Not answering your question, but relating to the solution that you've chosen: Combining different portlets this way (interdependent) is not quite an ideal way of packaging code. Personally, I'd prefer to rather use common display routines rather than making one concrete portlet dependent on another concrete portlet.