Custom Module Search

I have a Custom Module on this page (https://www.scopal.co.uk/videos) that I would like to be able to search all words and content used in this Custom Module - the results are set to show on this page (https://www.scopal.co.uk/video-search-results) - but I can not get it to work.

This is the code I am using - I would like it to search all content in the module not just keywords.

Hi @Dawn. The set up you have looks correct.
And keyword search will check the module items ‘Name’, ‘Description’ and ‘Site Search Keywords’ fields.

The only things I can suggest so far is to double check your ‘moduleId’ is correct in the form code and that your component tag on the search results page is configured correctly with the isSearchResult: "true" parameter and is referencing a valid list layout.

Hi Adam - sorry I dont understand your answer
On my search results page I am using this code;

 {% component source: "Page", layout: "Site Search List", displayPagination: "true", emptyMessage: "No items found by keyword: <strong>{{request.request_url.params.SearchKeyword}}</strong>", type: "site_search", limit:100, object:"collection" %}

The code I am using on the search page is

@Adam.Wilson @Dawn I think you guys have mixed up site search and module search. Dawn’s latest code sample (the component tag, the part starting with “</aside>” I don’t get as the screenshot is not showing for me) is for site search, you need to put this on the results page. And the search form needs to have this code: action="[URL of you results page]" in the form tag.
@Adam.Wilson you comment is referring to search within a specific module (hence the question about having the right module id and isSearchResult: "true" in the module tag. Unfortunately using the keyword field in the module search form is only working for keywords you put in the keyword field of item settings. I would have hoped it also searches in the name and description fields - but that doesn’t seem to work. The form for module search can be generated in the component manager here:

Hi

Sorry I am really confused now - just to recap - I have created a custom module for videos on this page (https://scopal.treepl.co/videos)
I would like people to be able to search the content of this video module only (not a site wide search) and the results to be shown on a new page -
My coding is not great so any code hints are really gratefully received but would need to be the complete code .
This is the code I am using at the moment. (sorry I have had to show as a screen grab as it doesnt show when I paste into this form)

@Dawn The code on the results page your’re using is for site search. If you want to do search in a module you get the right code in the component manager here:

(1) give you the code for the form; (2) is for the results. It’s basically the component tag for the module with isSearchResult: "true" (as @Adam.Wilson mentioned) added to the parameters. It works right away if both are on he same page. With a separate results page you need to add action="[URL of your results page]" to the form tag of the search form (but I think you already did that).
Now here is the thing: The keyword field in the module search form doesn’t seem to work for item names and descriptions (unfortunately). I just tried that as I also have a use case for this. Only works on the keywords property. For name and description you would have to use site search which then again is giving you results for the entire site. @Adam.Wilson Am I right with this?

@TimL I think something has changed with module search because the generated form code it gives now outputs the Site Search Keywords field, which yes, will only search that specific field. ie:

<input type="text" name="prop_SiteSearchKeywords">

However, I’m sure it used to output a special KeyWords field. But now it doesn’t.
But this field still works for module search and looks at Name Description and Site Search Keyword fields together:

<input type="text" name="prop_KeyWords">

So, in your case @Dawn, you just need the correct module tag on your search results page as Tim mentions above. Which should be something like this:

{% component source: "2004", layout: "List", isSearchResult: "true", type: "module" %}

Meanwhile, I’ll see if I can clarify what’s happening with the KeyWords field…

1 Like

Thanks, @Adam.Wilson! That works …

Cool. I think it’s a bug that the KeyWords field is no longer being added to the search form code via the toolbox.
Vlad is looking into it.

Sorry for the slow reply - thank you for your help - that works yeah