Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: Theme Search Bar destination search page configuration.
Hi everyone.
liferay version : portal-7.4-ga99
I want to customize search page without search page template.So I have a search bar injected in my theme header in the following way :
<#assign search_preferences =
freeMarkerPortletPreferences.getPreferences({"portletSetupPortletDecoratorId":
"barebone", "destination":
"/search-page"}) /> <@liferay.search_bar
default_preferences="${search_preferences}" />
I passed destination param to redirect to my custom search page
which has "/search-page" friendly url.
But when I hit the search button , I've been redirected to
default search page. So I decided to try add search bar widget
manually and set destination page
to "/search-page" , it works fine.
What I aslo noticed is that this search bar has portletId : com_liferay_portal_search_web_search_bar_portlet_SearchBarPortlet_INSTANCE_ibds
and my theme search bar is different somehow : com_liferay_portal_search_web_portlet_SearchPortlet_INSTANCE_templateSearch
Even though I see that
under @liferay.search_bar lays portletProviderClassName="com_liferay_portal_search_web_search_bar_portlet_SearchBarPortlet"
property
What am I missing here ? How can I also remove my current theme search bar and replace it with a new one if I'd have to (as I tested , it's not being updated when I change destination preference in it) ? Thanks.
I'd recommend to drop the old habit of injecting portlets into pages or layout templates, and rather go through the UI with Content Pages and Master Pages. This is so much more interactive, no need to develop or deploy anything.
That being said, to debug what you currently have: This project/plugin might help you identify the required preferences. It's an ugly UI, but shows what is currently configured.
If I recall correctly, those preferences will be stored with the page the first time you view the page. To update them, you'd have to get rid of the existing preferences using the API, or change the instance id. Another reason why Master Pages are so much more comfortable.
Thanks , I used this aproach (change instance id) with
@liferay.navigation_menu , but
unfortunately @liferay.search_bar macro doensn't
have such param. I also know that theme-less approach
is a better solution , I just practising themes development as legacy
project might have use it ...
Do you know which API can I use to
get rid of the existing preferences ?
The API would be very similar to the API used in the linked plugin. Just writing instead of reading (be careful...)
As of "legacy use": You're upgrading anyway, and might as well get rid of legacy technique during the upgrade, to make your life easier.
Not only my life , but other devs' too :)
My Liferay version is Liferay DXP-2024.q3.0. I did the same thing today and it works for me.
<#assign preferences =
freeMarkerPortletPreferences.getPreferences({"portletSetupPortletDecoratorId":
"barebone", "destination": "/search"})
/>
<@liferay.search_bar
default_preferences="${preferences}" />
I don't think you need to add or edit any parameters since this
code is the same as the source code of theme-classic.
However, I have no clue why it doesn't work to you.
Powered by Liferay™