CMS Development

DanBQ
Teilnehmer/-in | Elite Partner
Teilnehmer/-in | Elite Partner

Multilingual search function

lösung

Hi, I am trying to target language-specific search results in the hubspot search function on this site https://www.cogencyglobal.com/en-gb/ at the moment it shows everything on the us site and uk site when using the site search functions.

 

I know when I add the prefix &language=en-gb to the end of a search it works. EG: https://www.cogencyglobal.com/search?term=court+searches&language=en-gb but I'm unsure about how to actually implement this so it automatically adds the prefix if you're using the search function on the UK site.

 

On a side note - I also need a UK version on the search results page - this isn't an option in HubSpot, are there any workarounds?

 

Many thanks

0 Upvotes
2 Akzeptierte Lösungen
Stephanie-OG
Lösung
Autorität

Multilingual search function

lösung

Hey Dan, 

 

You can clone the "Site Search Input" module to create your own custom search and add in hidden inputs to specify parameters. So you could add in the limit like this: 

 

<input type="hidden" name="limit" value="5">

 

or the language like this: 

 

<input type="hidden" name="language" value="en-gb">

 

You can add it in below HubSpot's parameters:

 

language parameter.png

 

What I'm struggling a little with is setting the language condition to check for the page language. In theory you should be able to use content.language.languageTag to get the language like this:

 

{% if content.language.languageTag == "en-gb" %}
  <input type="hidden" name="language" value="en-gb">
{% endif %}

But it doesn't seem to be working for me :S

 

I suppose you could also set it directly in the module similar to the settings HubSpot has for content types. 

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

Lösung in ursprünglichem Beitrag anzeigen

Yves_LAURISSE
Lösung
Mitglied

Multilingual search function

lösung

Hi Dan,
Maybe I'm a little late (I've only been on hubspot for 2 weeks) but I have a good solution for your question regarding multilingual search :
1) just create an empty web page. The slug maybe /search or /en/search for example

2) add two modules by drag&drop : Search Input and Search Result

3) in the parameters of the Search Input you can choose on which page you want to see your result => choose this page : this the most important point. In the end you won't need to use the global prameter regarding the search result if you do that on every search input you have on your website.image.png

4) you can create as many multilingual page of this page as needed. Obviously you will have to change the search result page in the parameter of the search input module of each page to match with the right language.

 

That's it!

 

To improve the solution, you can clone the module search Input to add a filter '?language=xxx' to ensure that each search input will search only in the language of the page. I did this to avoid multiple results for the same blog with different languages. Example : Blog Quadza Software

In my case I have onyl two languages : en & fr

Yves_LAURISSE_0-1727965288501.png

{% if content.language.languageTag == "en" %}
<input type="hidden" name="language" value="en">
{% elif content.language.languageTag == "fr" %}
<input type="hidden" name="language" value="fr">
{% endif %}

 

I hope it helps

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
4 Antworten
Yves_LAURISSE
Lösung
Mitglied

Multilingual search function

lösung

Hi Dan,
Maybe I'm a little late (I've only been on hubspot for 2 weeks) but I have a good solution for your question regarding multilingual search :
1) just create an empty web page. The slug maybe /search or /en/search for example

2) add two modules by drag&drop : Search Input and Search Result

3) in the parameters of the Search Input you can choose on which page you want to see your result => choose this page : this the most important point. In the end you won't need to use the global prameter regarding the search result if you do that on every search input you have on your website.image.png

4) you can create as many multilingual page of this page as needed. Obviously you will have to change the search result page in the parameter of the search input module of each page to match with the right language.

 

That's it!

 

To improve the solution, you can clone the module search Input to add a filter '?language=xxx' to ensure that each search input will search only in the language of the page. I did this to avoid multiple results for the same blog with different languages. Example : Blog Quadza Software

In my case I have onyl two languages : en & fr

Yves_LAURISSE_0-1727965288501.png

{% if content.language.languageTag == "en" %}
<input type="hidden" name="language" value="en">
{% elif content.language.languageTag == "fr" %}
<input type="hidden" name="language" value="fr">
{% endif %}

 

I hope it helps

0 Upvotes
Stephanie-OG
Lösung
Autorität

Multilingual search function

lösung

Hey Dan, 

 

You can clone the "Site Search Input" module to create your own custom search and add in hidden inputs to specify parameters. So you could add in the limit like this: 

 

<input type="hidden" name="limit" value="5">

 

or the language like this: 

 

<input type="hidden" name="language" value="en-gb">

 

You can add it in below HubSpot's parameters:

 

language parameter.png

 

What I'm struggling a little with is setting the language condition to check for the page language. In theory you should be able to use content.language.languageTag to get the language like this:

 

{% if content.language.languageTag == "en-gb" %}
  <input type="hidden" name="language" value="en-gb">
{% endif %}

But it doesn't seem to be working for me :S

 

I suppose you could also set it directly in the module similar to the settings HubSpot has for content types. 

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

DanBQ
Teilnehmer/-in | Elite Partner
Teilnehmer/-in | Elite Partner

Multilingual search function

lösung

Perfect solution, thank you!

0 Upvotes
Stephanie-OG
Autorität

Multilingual search function

lösung

I'm glad that helped! Smiley (fröhlich) I also wrote a post that hopefully anyone else who comes across this might find useful: Add parameters to your HubSpot site search input module

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

0 Upvotes