Gravatar for

Question by debu_biswas, Feb 19, 2019 1:00 PM

Coveo Hive - Redirect to custom search page

I am using coveo for sitecore 5 Hive. While using he global search box, I noticed that we need to now set the datasource for the search box where in a sitecore field i can specify the the target search page. But scenarios where we have multiple sites all using the global search box, if we go by this route, all pages where we display the global search box, I will have to make sure the datasource is pointing to the right global search box. This will be tremendous effort on my end where I will have to datasource each and every sitecore item in a site. In coveo for sitecore 4.1, I was able to handle this by adding some code in the "searchboxview.cshtml" inside the "Coveo.$(function ()" to achieve such that regardless of what you set the "search page" at the rendering level, I was able to compute the search page based on the context site and modify it. How do i achieve this in Coveo for siteore 5.0?

1 Reply
Gravatar for

Answer by François Lachance-Guillemette, Feb 19, 2019 2:41 PM

You can still duplicate the `Coveo Searchbox` component, though I would recommend against it if possible.

I tried to find some entry point to put your code, and I think, as of now, you have no choice.

You must duplicate the `Views/Coveo Hive/Search Boxes/Coveo Searchbox.cshtml` file, then the `Views/Coveo Hive/Initialization/Initialize Searchbox.cshtml` file.

In the `Coveo Searchbox` file, you can replace the initialization script by your own on the following line:

@Html.Coveo().InitializationPartial(Initializers.SEARCHBOX, Model)

with the following line:

@Html.Partial("~/Views/YOURPATH/YOURFILE", Model)

Then you can modify your Custom Initialize Searchbox.cshtml with any code you want.


Now, I understand this is not quite easy, and we want to provide all the tools required for you to not duplicate components, so I have entered an issue on our side to simplify this process. Stay tuned! :)

Gravatar for

Comment by debu_biswas, Feb 19, 2019 3:56 PM

@François Lachance-Guillemette you rock!

This is exactly what I needed. Something similar to how I achieved this on Coveo for sitecore 4.1 (see my blog at "").

Ask a question