public async Task <NavigationItem> GetTreeNodeToNavAsync(Guid linkPageIdentifier) { var DocQuery = DocumentHelper.GetDocuments() .WhereEquals("NodeGuid", linkPageIdentifier) .Culture(_repoContext.CurrentCulture()) .CombineWithDefaultCulture() .CombineWithAnyCulture() .OnCurrentSite() .Columns(nameof(TreeNode.DocumentName), nameof(TreeNode.ClassName), nameof(TreeNode.DocumentCulture), nameof(TreeNode.NodeID), nameof(TreeNode.DocumentID), nameof(TreeNode.DocumentGUID), nameof(TreeNode.NodeGUID), nameof(TreeNode.NodeAliasPath)); if (!_repoContext.PreviewEnabled()) { DocQuery.Published(); } else { DocQuery.LatestVersion(true); DocQuery.Published(false); } var TreeItem = DocQuery.FirstOrDefault(); if (TreeItem == null) { return(null); } return(_Mapper.Map <NavigationItem>(TreeItem)); }
public async Task <TreeNode> GetBreadcrumbNodeAsync(int NodeID) { return(DocumentHelper.GetDocuments() .WhereEquals("NodeID", NodeID) .Culture(_repoContext.CurrentCulture()) .CombineWithDefaultCulture() .CombineWithAnyCulture() .Published(!_repoContext.PreviewEnabled()) .LatestVersion(_repoContext.PreviewEnabled()) .FirstOrDefault()); }
private IEnumerable <ITreeNode> GetDocumentsByPathInternal(string SinglePath, string SiteName, PathSelectionEnum PathType, string OrderBy = null, string WhereCondition = null, int MaxLevel = -1, int TopNumber = -1, string[] Columns = null, string[] PageTypes = null, bool IncludeCoupledColumns = false, string Culture = null) { MultiDocumentQuery Query = new MultiDocumentQuery(); if (PageTypes != null && PageTypes.Length > 0) { if (PageTypes.Length == 1) { Query.Type(PageTypes[0]); } else { Query.Types(PageTypes); } } if (IncludeCoupledColumns) { Query.ExpandColumns(); } // Handle culture and versioning and site Query.Culture(Culture) .CombineWithDefaultCulture() .CombineWithAnyCulture() .Published(!_repoContext.PreviewEnabled()) .LatestVersion(_repoContext.PreviewEnabled()) .OnSite(SiteName); PathTypeEnum KenticoPathType = PathTypeEnum.Explicit; switch (PathType) { case PathSelectionEnum.ChildrenOnly: KenticoPathType = PathTypeEnum.Children; break; case PathSelectionEnum.ParentAndChildren: KenticoPathType = PathTypeEnum.Section; break; case PathSelectionEnum.ParentOnly: KenticoPathType = PathTypeEnum.Single; break; } Query.Path(SinglePath, KenticoPathType); if (!string.IsNullOrWhiteSpace(OrderBy)) { Query.OrderBy(OrderBy); } if (!string.IsNullOrWhiteSpace(WhereCondition)) { Query.Where(WhereCondition); } if (Columns != null && Columns.Length > 0) { Query.Columns(Columns); } if (MaxLevel >= 0) { Query.NestingLevel(MaxLevel); } if (TopNumber >= 0) { Query.TopN(TopNumber); } return(Query.TypedResult); }