I'm new in hubspot and i'm trying to edit Search Input Module in order to exclude some blog from the search result, but when i'm trying to compare URL to extract the blog posts i got this type of URL:
<a href="/_hcms/analytics/search/conversion?redirect=aHR0cDovL2Jsb2cuZmlyc3RhbS5jb20vY29tbWVyY2lhbC9ueWMtYW5kLW55cy10cmFuc2Zlci10YXhlcy1kaXN0aW5ndWlzaGVk&ct=AUTOCOMPLETE&pid=17501&cid=4414850610&t=bnlj&d=blog.firstam.com&c=1&c=2&c=3&rp=1&hs-expires=1563282361&hs-version=1&hs-signature=APUk-v4DIIjdLGcn8P9_0xuIO_csWHgB2A"><span class="hs-search-highlight hs-highlight-title">NYC</span> and NYS Transfer Taxes Distinguished</a>
Which of course is not a "normal" URL where a can take first parameter and exclude and so on...
The thing i would like to accomplish is to compare first URL parameter after "/" and show or hide accordingly.
I'm trying to do that in this function, i want to exclude "myblog1" post from results:
fillSearchResults = function(results){
var items = [];
items.push( "<li id='results-for'>Results for \"" + searchTerm + "\"</li>" );
results.forEach(function(val, index) {
var title = val.title,
resultUrl = val.url,
resultDescription = val.description;
if(resultUrl.split("/").filter(String)[0] == "myblog1")
{
return;
}
items.push( "<li id='result" + index + "'><a href='" + resultUrl + "'>" + title + "</a></li>" );
});
emptySearchResults();
searchResults.innerHTML = items.join("");
searchForm.classList.add('hs-search-field--open');
},
@karensantana - If you've cloned the search results module so that you can edit it, you can remove the analytics links from the XHR response. Just change this to analytics=false
If this answer helped, please, mark as solved 😄
tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.