Gravatar for daugustine@habaneroconsulting.com

Question by Dennis Augustine, Jan 29, 2019 11:44 PM

Hive Tabs Filter by Language

I planned on using the Coveo Hive Framework for displaying results from multiple sites and sources, some of which don't have exactly the same language set ("en" and "fr" in one case, "en-ca" and "fr-ca" in another and "English" and "French" in some external sources).

With the Legacy Framework I could set the Coveo Search View to not filter by language but then add tabs with rules on them so as to set a language filter for that tab on the final version of the presentation. With the Hive Framework however, the Filter expression rule for tabs is a shared field, meaning this method won't work.

How can I work around this? One thought I had was to set a different datasource on the final rendering for the tabs but this is really inelegant. Any other ideas?

1 Reply
Gravatar for flguillemette@coveo.com

Answer by François Lachance-Guillemette, Jan 30, 2019 1:02 PM

For most people, it makes more sense to have the `Filter expression rules` field as shared since they don't want to replicate the expression for each language.

This is the first time I see this use case, and it also makes sense. This is debatable, but I still think "shared" should be kept as the default.

I guess the best you could do for now is un-shared it.

For a more long-term change, you could duplicate some templates. If you follow the "Coveo Tab" data source (`/template/Coveo Hive/Tabs/Coveo Tab`), you can see it is constructed with the following templates:

  • /template/Coveo Hive/Base UI Component
  • /template/Coveo Hive/Scopes/External Content
  • /template/Coveo Hive/Scopes/Query Filter
  • /template/Coveo Hive/Scopes/Query Ranking

Which means you could duplicate the `Query Filter` one into a `Version-Specific Query Filter`, and duplicate the `Coveo Tab` one to inherit from those four instead:

  • /template/Coveo Hive/Base UI Component
  • /template/Coveo Hive/Scopes/External Content
  • /template/Coveo Custom/Version-Specific Query Filter
  • /template/Coveo Hive/Scopes/Query Ranking

Then duplicate the Coveo Tab rendering to instead point to this data source.

----

If you want to get your hands into some code, you could also drive the expressions using JavaScript. It would be possible to detect the language and change the expression accordingly.

The CoveoForSitecoreFilterExpression component is quite easy to use and can use the scScopeToTab attribute to apply the filter to a single tab.

Hope this helps!

Gravatar for daugustine@habaneroconsulting.com

Comment by Dennis Augustine, Jan 30, 2019 4:29 PM

Thanks for that François. I think that sounds like a viable approach.

Ask a question