Jul 16, 2018 9:28 AM
Hello Community!
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'); },
Is there a way to get the "regular" URL in order to compare it, ex: www.blog.com/myblog1/myfirstblogpost
Jul 16, 2018 11:30 AM
@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.
Drop by and say Hi to me on slack.
Jul 16, 2018 12:44 PM
I got an idea, maybe i can add the ID of the blog as a parameter in this line:
var searchUrl = "/_hcms/search?&term="+encodeURIComponent(searchTerm)+"&limit="+encodeURIComponent(TYPEAHEAD_LIMIT)+"&autocomplete=true&analytics=true&" + searchOptions();
Do you know how can i accomplish that?
Jul 16, 2018 11:33 AM
Where is that code located? In Search Input Module?
Jul 16, 2018 11:41 AM
Search results module. I believe it's under the "more" button then, choose to edit the module code.
Jul 16, 2018 12:05 PM
I mean, the thing that i want to accomplish is to get the name of the blog using that URL. Is that possible?