Foren
Search Portlet in Custom theme in Liferay 7
Durga prasada Rao Kasina, geändert vor 6 Jahren.
Search Portlet in Custom theme in Liferay 7
New Member Beiträge: 21 Beitrittsdatum: 26.07.12 Neueste Beiträge
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.
Yannis Sinadinos, geändert vor 6 Jahren.
RE: Search Portlet in Custom theme in Liferay 7
Junior Member Beiträge: 39 Beitrittsdatum: 20.03.17 Neueste Beiträge
I managed to display the navigation menu with this code in portal_normal.ftl
and search with the following code:
<#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() />
Andrew Jardine, geändert vor 6 Jahren.
RE: Search Portlet in Custom theme in Liferay 7
Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
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.
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.