Currently all Coveo UI components are initialized through Experience Editor. Setting their appropriate properties. Is there a way to initialize them through code? Example CoveoSortFieldView.cshtml and CoveoFacetView.cshtml

I would like to reference them in code and load a perticular facet instead of going through EE.

Using Coveo for Sitecore 4.

1 Answer 1


Yes you can. You can simply use a reference to the rendering. Be aware that you will also need to pass a datasource reference with the rendering for the options.


1- Create a parameters item which you will use as a datasource, the template of these items is in the template/coveomodule folder.

2- Pass the refference of the rendering and your datasource item in your code.

Here is an example for the search box in a cshtml header:

<!-- The resources first -->
<!-- Then the search box item -->
@Html.Sitecore().Rendering("{id-of-the-search-box-view-rendering}", new { DataSource = "{parameters-item-of-the-search-box-view}" })
  • Thanks, do you have an example of how to set ds parameters? I am little confused as to what goes under {parameters-item-of-the-search-box-view}. I'd imagine this depends on the type of rendering but an example should help me greatly.
    – xoail
    Dec 6, 2016 at 15:21
  • Well in the Sitecore Content Editor, look under Layout >> Renderings >> Coveo and you will see all our components. Simply take the id of the component you need to include in the page, in my example above it would be the Search Box View Dec 6, 2016 at 16:12
  • {parameters-item-of-the-search-box-view} should be the GUID of an item in the content tree. That item should use the template for the type of datasource parameters of the search box. Dec 6, 2016 at 22:30
  • Thanks! just to confirm if I am using the Facet component, then I have to create an item using /sitecore/templates/CoveoModule/Search/Facet Parameters template and set its ID as my rendering's datasource?
    – xoail
    Dec 7, 2016 at 3:13
  • 1
    Yes, an item that inherits from the Facet Parameters template. Actually, in the same Search folder you should see a facet folder. You can create a folder that inherits from that folder. That new folder will have the insert options for all the facet parameters. Dec 7, 2016 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.