maio 09, 2019
Using the Coveo component in Sitecore to create a customized omnibox.
For a recent project, I needed to create a customized omnibox that included result items, grouped in categories (Based on Page Templates), and a View All button that redirected the users to the search page.
Then I had to get the omnibox object (the object that kept the search result). The code for that was as follows:
Then I had to predefine a deferrer and push it to the rows of the omnibox object, so that after the search results are back and the deferrer got resolved by the search results, the results could be added to the omnibox object rows, and my newly created rows could be populated. Here is the code for that:
I then needed to use the results values to populate the omnibox. To do so I created a simple HTML element and added that to the omnibox object.
Then I had to create an object using the HTML element and add it to the deferrer, so it can be pushed to the omnibox.
The full code would look like this: