CMS Development

annaboateng
Participant

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.  

 

{% if module.content_types.hubdbtable_field %}
<input type="hidden" name="table_name" value="testing_search">
{% endif %}

 

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! 

0 Upvotes
1 Accepted solution
Phil_Vallender
Solution
Most Valuable Member | Diamond Partner
Most Valuable Member | Diamond Partner

Custom search module for site pages and HubDB rows

SOLVE

Hi @annaboateng 

 

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.

 

Hope this helps.

 

Phil Vallender | HubSpot Website Agency

View solution in original post

4 Replies 4
NChappell
Member

Custom search module for site pages and HubDB rows

SOLVE

Did you ever find a solve for this other than the suggestions from Phil?

0 Upvotes
annaboateng
Participant

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 %}

0 Upvotes
annaboateng
Participant

Custom search module for site pages and HubDB rows

SOLVE

Yeah I have been searching all over for an answer to this but could not find a conclusive answer. 

 

I was able to add the HubDB table as an search option in the design manager but not sure where to go from there

annaboateng_0-1720452013818.png

 

0 Upvotes
Phil_Vallender
Solution
Most Valuable Member | Diamond Partner
Most Valuable Member | Diamond Partner

Custom search module for site pages and HubDB rows

SOLVE

Hi @annaboateng 

 

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.

 

Hope this helps.

 

Phil Vallender | HubSpot Website Agency