How can I embed a widget in another widget template in Liferay?

Author: Ajay Choudhary

Liferay Version: 7.4

You can embed a widget in another widget template in Liferay by using the liferay_portlet["runtime"] macro. Here’s an example of how you can do this:

<@liferay_portlet["runtime"]
    instanceId="unique_id"
    portletName="<%=innerWidgetPortletId%>"
/>

In the above code, replace <%=innerWidgetPortletId%> with the actual portlet ID of the inner widget. For example, if you’re embedding the Sort Portlet, your code would look like this:

<@liferay_portlet["runtime"]
    instanceId="search_result_sort"
    portletName="com_liferay_portal_search_web_internal_sort_portlet_SortPortlet_INSTANCE_nndp_sortSelection"
/>

This will embed the Sort Portlet within your widget template. Remember to replace "search_result_sort" and "com_liferay_portal_search_web_internal_sort_portlet_SortPortlet_INSTANCE_nndp_sortSelection" with your actual instance ID and portlet name, respectively.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

close
Thanks !

Thanks for sharing this, you are awesome !