Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

How to define a conditional query filter for language?

Vote:
 

I need to filter a page type by the current language and if it is not available then filter by 'en'. 

I tried this, but it returns both current language and 'en' instances. 

languageFilter.Or(x => x.LanguageID.MatchCaseInsensitive(currentLang) | (!x.LanguageID.MatchCaseInsensitive(currentLang) & x.LanguageID.MatchCaseInsensitive("en")));



I need 'en' content only if current langage instance is not available. 

Can I define such a query filter ?

#140288
Oct 15, 2015 6:55
Vote:
 

Try using the "PageLanguages" property instead of the LanguageID.

#140355
Oct 16, 2015 13:44
Vote:
 

If only the "PageLanguages" property was matched, it only shows the pages of current language.

But I want to retrieve EN pages if there's no language branch in current language. 

I tried this but it doesn't work. 

languageFilter = languageFilter.Or(x => x.PageLanguages.Match(languageId) & x.LanguageID.MatchCaseInsensitive(languageId));
languageFilter = languageFilter.Or(x => !x.PageLanguages.Match(languageId) & x.LanguageID.MatchCaseInsensitive("en"));

#140398
Oct 19, 2015 11:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.