Foros de discusión

Search Portlet in Custom theme in Liferay 7

Durga prasada Rao Kasina, modificado hace 6 años.

Search Portlet in Custom theme in Liferay 7

New Member Mensajes: 21 Fecha de incorporación: 26/07/12 Mensajes recientes
I have created a custom theme in Liferay 7 and clone it as classic theme. I have added the theme to portlet but i am not able to see search portlet and navigation portlet in the theme. can anybody help me display search and navigation portlets in my custom theme.
thumbnail
Yannis Sinadinos, modificado hace 6 años.

RE: Search Portlet in Custom theme in Liferay 7

Junior Member Mensajes: 39 Fecha de incorporación: 20/03/17 Mensajes recientes
I managed to display the navigation menu with this code in portal_normal.ftl

<#assign
		VOID = freeMarkerPortletPreferences.setValue("displayDepth", "1")
		VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone")
/>

<@liferay.navigation_menu
		instance_id="main_navigation_menu"
		default_preferences="${freeMarkerPortletPreferences}"
/>

<#assign VOID = freeMarkerPortletPreferences.reset() />


and search with the following code:

<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />

				<@liferay.search default_preferences="${freeMarkerPortletPreferences}" />

				<#assign VOID = freeMarkerPortletPreferences.reset() />
thumbnail
Andrew Jardine, modificado hace 6 años.

RE: Search Portlet in Custom theme in Liferay 7

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
I've used something similar to this as well. The one thing I found though is that because this is in the theme, you end up setting the portlet preferences every time the page loads, even if the preferences are already there, To get around this, I added a custom preference to the list with a version number. When I load the page, I check the version number and if it is the same as the stored value, then I skip the "saving preferences" logic and just render the portlet.

It does require redeploying the theme when you want to update the preferences, but that is a minor tradeoff as compared to skipping a bunch of database calls that are unnecessary.