CMS Development

karensantana
Member

How can i convert Hubspot Search Result URL ?

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&amp;ct=AUTOCOMPLETE&amp;pid=17501&amp;cid=4414850610&amp;t=bnlj&amp;d=blog.firstam.com&amp;c=1&amp;c=2&amp;c=3&amp;rp=1&amp;hs-expires=1563282361&amp;hs-version=1&amp;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

 

 

 

0 Upvotes
5 Replies 5
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

How can i convert Hubspot Search Result URL ?

@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

ser-clone.png


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.

0 Upvotes
karensantana
Member

How can i convert Hubspot Search Result URL ?

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?

karensantana
Member

How can i convert Hubspot Search Result URL ?

Where is that code located? In Search Input Module?

0 Upvotes
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

How can i convert Hubspot Search Result URL ?

Search results module. I believe it's under the "more" button then, choose to edit the module code.

0 Upvotes
karensantana
Member

How can i convert Hubspot Search Result URL ?

I mean, the thing that i want to accomplish is to get the name of the blog using that URL. Is that possible?