Skip to content

Commit 990b587

Browse files
author
Viktor Sahlström
committed
In order to view content that has no language, the language filter is changed to match content that is not Localizable or has the same language as the current language. The filter is also moved behind the For in order to avoid a bug making filter added before the For to be ignored.
1 parent 7acb11d commit 990b587

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

PowerSlice/ContentSliceBase.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
namespace PowerSlice
1717
{
18-
public abstract class ContentSliceBase<TContent> : ContentQueryBase, IContentSlice, ISortableContentSlice<TContent>
19-
where TContent : IContentData
18+
public abstract class ContentSliceBase<TContent> : ContentQueryBase, IContentSlice, ISortableContentSlice<TContent>
19+
where TContent : class, IContentData
2020
{
2121
protected IClient SearchClient;
2222
protected IContentTypeRepository ContentTypeRepository;
@@ -38,8 +38,7 @@ public override QueryRange<IContent> ExecuteQuery(IQueryParameters parameters)
3838
{
3939
var contentQueryParam = parameters as ContentQueryParameters;
4040

41-
var searchRequest = SearchClient.Search<TContent>()
42-
.FilterOnLanguages(new[] { contentQueryParam.PreferredCulture.Name });
41+
var searchRequest = SearchClient.Search<TContent>();
4342

4443
var searchPhrase = parameters.AllParameters["q"];
4544
var hasFreeTextQuery = !string.IsNullOrWhiteSpace(searchPhrase) && searchPhrase != "*";
@@ -48,6 +47,8 @@ public override QueryRange<IContent> ExecuteQuery(IQueryParameters parameters)
4847
searchRequest = ApplyTextSearch(searchRequest, searchPhrase);
4948
}
5049

50+
searchRequest = searchRequest.Filter(x => !x.MatchTypeHierarchy(typeof(ILocalizable)) | ((ILocalizable)x).Language.Name.Match(contentQueryParam.PreferredCulture.Name));
51+
5152
searchRequest = Filter(searchRequest, contentQueryParam);
5253

5354
searchRequest = ApplyVisibilityFilter(searchRequest);

0 commit comments

Comments
 (0)