Custom search module for site pages and HubDB rows
SOLVE
Hi, I am trying to create a custom search page that searches both site pages and a HubDB table (the table has a URL row that references external pages).
I tried cloning the default search input page and edited the "Search results include" options to include a hubDB table. I also added a hidden input type with the table name.
I am assuming there is more to it than this, and I am not even sure if its even possible to combine search results in this way. The requestURL for internal pages must be different from the requestURL for HubDB rows...?
I am new to CMS dev and know only basic JS so any help would be much appreciated!
As far as I am aware it may not be possible to customise the native HuBSpot search module to search in and return results from within a HubDB table. Other discussions on the topic appear to be inconclusive:
If the content has indexable pages, either auto-generated or linked, my suggestion would be to look at implementing a thirdparty solution instead - something like Swiftype or Site Search 360.
Custom search module for site pages and HubDB rows
SOLVE
I ended up creating a search page with two custom modules in it, one was the regular search module and one that filtered a hubDB table and returned the results as a list. I set the queryParam to use the search term in the url.
There are probably more elegant solutions but this worked for our purposes!
For the custom HubDB search module:
{% set queryParam = "" %} {% set searchTerm = request.query_dict['term'] %}
{% set queryParam = "tags__icontains="~searchTerm %}
{% if searchTerm %} <p> <b>Suggested Support Articles</em> </p> <ul> {% set rows = hubdb_table_rows(module.hubdbtable_field, queryParam) %} {% for row in rows %} <li><a href="{{ row.url }}">{{ row.title }}</a></li> {% endfor %} </ul> {% endif %}
As far as I am aware it may not be possible to customise the native HuBSpot search module to search in and return results from within a HubDB table. Other discussions on the topic appear to be inconclusive:
If the content has indexable pages, either auto-generated or linked, my suggestion would be to look at implementing a thirdparty solution instead - something like Swiftype or Site Search 360.