2 min read

Unkown little fact about Multilist with search

Unkown little fact about Multilist with search

I learned something about Multilist with search that I thought was impossible but apparently has been a feature since Sitecore 7!

What's it about

Earlier this week I was working on an implementation of Articles to be shown on a website. And each article needs to display a list of Related articles.

Since we have a lot of articles, they are stored in a Bucket. So for the Related articles field, a Multilist with search is the best option!

Our site is also multilingual and articles can have 1 or more languages.

What I want

I want to show the articles in the language version of the current item in the Multilist with search selection panel.

The default functionality of a Multilist with search is that it will display all items in every language it is available.

As some/everyone probably knows, you can limit this field to a specific language.
In the Source of the field, you can set filters and add Language=english.
Example:

StartSearchLocation={FB5AF476-B4B7-4C51-9879-F45F8AE9E940}
&Filter=_templatename:Article&Language=english

This will limit the available articles to be selected, but only English articles are visible and selectable.

More about the options for Multilist with search can be read here (blog posts from 2013!):

In the screenshot above, you can see 4 articles. 'My first article' is only English, '2nd article' is English and Dutch, 'Derde artikel' and '4e artikel' only has a Dutch version.
Using the default language filter will only limit the articles for 1 specific language.

What I want is:

  • when the editor is viewing the Dutch version of an article, that he can only select the Dutch articles. (2nd article, Derde artikel and 4e artikel)
  • when the editor is viewing the English version of an article, that he can only select the English articles (My first article and 2nd article)

The solution

The solution is pretty simple.
Because there is functionality to achieve this without writing anything custom.

You can use the $CurrentLanguage token.

This works:

StartSearchLocation={FB5AF476-B4B7-4C51-9879-F45F8AE9E940}
&Filter=_templatename:Article&Language=$CurrentLanguage

Apparently this is available since Sitecore 7. But strangly enough, I couldn't find any official documentation about it nor other blog posts are mentioning it.

Hope this helps someone else too!

English language version
Dutch language version