Gravatar for

Question by wvuong, Dec 14, 2015 4:59 PM

Using different result template per tab

I want to use a different result template based on the tab selected. From what I can tell Coveo intends for data to grouped differently via tabs and not necessarily to be displayed differently.

Anyone have any thoughts on best practices with Coveo in order to support this?

I know I could utilize our own method and then call the correct coveo methods, but I feel like this is something that is probably supported but I am missing in the documentation.

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Dec 14, 2015 9:17 PM


I don't think there's an out of the box solution for that use case. I would implement it with the loadTemplate helper from the Coveo JavaScript Search Framework like this (pseudo-code here):

<script class="result-template" type="text/x-underscore-template">
  {{ var searchTab = Coveo.$('#search').coveo('state', 't'); }}
  {{= loadTemplate('tab1-result-template', searchTab === 'tab1') }}
  {{= loadTemplate('tab2-result-template', searchTab === 'tab2') }}
<script id="tab1-result-template" type="text/x-underscore-template">
<script id="tab2-result-template" type="text/x-underscore-template">

I hope this helps,


Ask a question