Gravatar for

Question by yonico, Feb 3, 2015 2:08 PM

coveo facet value caption

Hello - we are currently trying to use the valueCaption for facets and couldnt get it to work. This is the script we are running and not sure whats wrong.

<script type="text/javascript">
    Coveo.$(function() {
        CoveoForSitecore.componentsOptions = <%= Model.GetJavaScriptInitializationOptions() %>;


    $("#search").coveo("init", {
        Facet : {
            valueCaption : { "CatalogProduct" : "Text files"}


We tried different names from the facets and not seems to work. Can you provide a complete example value caption? Where can we get the Facet id for the caption?

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Feb 3, 2015 2:44 PM

By default, Coveo for Sitecore doesn't generate the id attribute for the standard facet component. It is however generated for the slider and range facets.

You can easily add it by adding this attribute in the CoveoFacet.ascx file:

 id="<%= Model.UniqueId %>"

Or this attribute in the FacetView.cshtml file:


Be warned that any upgrade of the Coveo for Sitecore product will replace those files and you will lose your changes. It is recommended to modify a copy of those files and create new layouts/renderings in Sitecore that uses your modified files.

For your example code, I see that you don't use the CoveoForSitecore.componentsOptions variable while initializing your JS UI. It is very important to use it as it contains all the initialization parameters configured inside Sitecore. You should follow the instructions to set custom initialization options:

You also initialize your search page with the 'coveo' jQuery plugin function instead of the coveoForSitecore jQuery plugin function. You should use the coveoForSitecore function inside Sitecore.

You should also always use Coveo.$ to use jQuery in a Coveo for Sitecore layout/view as $ can conflict with the prototypeJS library used by Sitecore themselves.

Your code should look like this to set the valueCaption for all the facets on your search page:

Coveo.$(function() {
    CoveoForSitecore.componentsOptions = <%= Model.GetJavaScriptInitializationOptions() %>;

    if (!CoveoForSitecore.componentsOptions.Facet) {
        CoveoForSitecore.componentsOptions.Facet = {};
    CoveoForSitecore.componentsOptions.Facet.valueCaption = { "CatalogProduct" : "Text files" };

    Coveo.$('#search').coveoForSitecore('init', CoveoForSitecore.componentsOptions);
Ask a question