I have added a search to our blog seen here
BETTER IMPACT BOOK BITES: The (Help!) I-Don’t-Have-Enough-Time Guide to Volunteer Management
I have the following code added to the JS but it is still not filtering
getSearchResults = function() {
var request = new XMLHttpRequest();
var requestUrl =
'/_hcms/search?&term=' +
encodeURIComponent(searchTerm) +
'&domain=blog.betterimpact.com' +
'&language=en' +
'&pathPrefix=en' +
'&type=BLOG_POST' +
'&limit=5' +
encodeURIComponent(TYPEAHEAD_LIMIT) +
'&autocomplete=true&analytics=true&' +
searchOptions();
Searching for video still pulls up blogs from the wrong domain, the wrong language, and even the wrong pathprefix. Not sure what i have missed.
That the actual results url is
https://blog.betterimpact.com/blog-search-results?term=video
rather than
https://blog.betterimpact.com/blog-search-results?term=video&domain=blog.betterimpact.com&language=en&pathPrefix=en&type=BLOG_POST&limit=5
would suggest to me that your javascript isn’t firing, do you have it tied to an event?
Honestly, I usually wouldn’t mess around with javascript in this case, I’d just clone the search module and set the fields the way I want them e.g.
<form action="/blog-search-results" data-hs-cf-bound="true">
<input type="text" class="hs-search-field__input" name="term" autocomplete="off" aria-label="Search" placeholder="">
<input type="hidden" name="type" value="BLOG_POST">
<input type="hidden" name="language" value="en">
/* etc */
</form>
Barry Grennan
Freelance HubSpot CMS Developer
Website | Contact