I have two questions related to the custom modules search form.
I set up a search form that works fine. When I do a search the results are displayed correctly. The problem is that when I access the page (before permform the search) all the items are displayed while I would like that the results will be diplayed only when the search is done.
The same search module is also displayed in a pop-up level and in a sidebar and I need to show the search results in a different page.
I don’t understand how to set the display of results on a specific page. Is it possible to set in the form action as in BC? Can I define via JS the page result?
Below is some sample code that does both, redirect your search form (via the addition of an action attribute), and displays the search component only when the search parameter is present in the URL:
<form action="/search-results-page"> <!-- this action attribute does the redirect -->
<input type="hidden" name="prop_ModuleId" value="1999" >
<label>Keywords</label>
<input type="text" name="prop_KeyWords" maxlength="255" value="{{request.request_url.params.prop_KeyWords}}" >
<input type="submit" value="Search" >
</form>
{% if request.request_url.params.prop_ModuleId %} <!-- this Liquid condition checks for the search param in the URL -->
{% component source: "Your Module", layout: "List", isSearchResult: "true", type: "module" %}
{% endif %}
Hi @Yunnek
Doesn’t look like any search term/keyword is working and all items are being returned with any search.
Double-check the module ID used in the search form is the correct ID of the Custom Module.
Also, try re-indexing the site.
If ID is correct and reindex doesn’t help, can you post the code you have on the search page.