Skip to content

Commit

Permalink
Fix Breadcrumb Repository returning the Root node (empty node) in the…
Browse files Browse the repository at this point in the history
… list.
  • Loading branch information
KenticoDevTrev committed Mar 10, 2022
1 parent e4faa1c commit a3f5f4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions MVC/MVC.Libraries/GlobalNamespaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
global using XperienceCommunity.QueryExtensions.Objects;
global using XperienceCommunity.QueryExtensions.Collections;
global using RelationshipsExtended;
global using CMS.DocumentEngine.Routing;

// Intefaces
global using Generic.Repositories.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using AutoMapper;
using CMS.DataEngine;
using CMS.DocumentEngine;

using CMS.Helpers;
using CMS.Localization;
using CMS.SiteProvider;
Expand Down Expand Up @@ -137,7 +138,15 @@ private async Task<Dictionary<int, Tuple<Breadcrumb, int>>> GetNodeToBreadcrumbA
// Cache dependency should not extend to the CacheDependenciesStore as only the matching breadcrumbs should apply.
var results = await _pageRetriever.RetrieveAsync<TreeNode>(
query => query
.Where($"NodeClassID not in (select ClassID from CMS_Class where ClassName in ('{string.Join("','", validClassNames.Select(x => SqlHelper.EscapeQuotes(x)))}'))"),
.Columns(new string[] {
nameof(TreeNode.DocumentName),
nameof(TreeNode.NodeID),
nameof(TreeNode.NodeParentID)
})
.Where("NodeClassID not in (select ClassID from CMS_Class where ClassName = 'CMS.Root')")
.WithPageUrlPaths()
.If(validClassNames.Length > 0, query => query.Where($"NodeClassID in (select ClassID from CMS_Class where ClassName in ('{string.Join("','", validClassNames.Select(x => SqlHelper.EscapeQuotes(x)))}'))")),

cacheSettings => cacheSettings
.Dependencies((items, csbuilder) => csbuilder.PagePath("/", PathTypeEnum.Section))
.Key($"GetNodeToBreadcrumbAndParent")
Expand Down

0 comments on commit a3f5f4e

Please sign in to comment.