diff --git a/src/Umbraco.Web/Trees/ContentTreeController.cs b/src/Umbraco.Web/Trees/ContentTreeController.cs index ea644f5dc8..aedb9b69f2 100644 --- a/src/Umbraco.Web/Trees/ContentTreeController.cs +++ b/src/Umbraco.Web/Trees/ContentTreeController.cs @@ -73,16 +73,17 @@ namespace Umbraco.Web.Trees var allowedUserOptions = GetAllowedUserMenuItemsForNode(e); if (CanUserAccessNode(e, allowedUserOptions)) { - //Special check to see if it ia a container, if so then we'll hide children. var isContainer = e.IsContainer(); // && (queryStrings.Get("isDialog") != "true"); + var hasChildren = ShouldRenderChildrenOfContainer(e); + var node = CreateTreeNode( entity, Constants.ObjectTypes.DocumentGuid, parentId, queryStrings, - entity.HasChildren && (isContainer == false)); + hasChildren); node.AdditionalData.Add("contentType", entity.ContentTypeAlias); @@ -253,4 +254,4 @@ namespace Umbraco.Web.Trees return _treeSearcher.ExamineSearch(Umbraco, query, UmbracoEntityTypes.Document, pageSize, pageIndex, out totalFound, searchFrom); } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs index 4705e16c7e..d4ccd88e5b 100644 --- a/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs +++ b/src/Umbraco.Web/Trees/ContentTreeControllerBase.cs @@ -203,7 +203,9 @@ namespace Umbraco.Web.Trees entityId = entity.Id; } - return Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToArray(); + var v2 = Services.EntityService.GetChildren(entityId, UmbracoObjectType).ToList(); + + return v2; } /// @@ -274,6 +276,37 @@ namespace Umbraco.Web.Trees return GetTreeNodesInternal(id, queryStrings); } + /// + /// Check to see if we should return children of a container node + /// + /// + /// + /// + /// This is required in case a user has custom start nodes that are children of a list view since in that case we'll need to render the tree node. In normal cases we don't render + /// children of a list view. + /// + protected bool ShouldRenderChildrenOfContainer(IUmbracoEntity e) + { + var isContainer = e.IsContainer(); + + var renderChildren = e.HasChildren() && (isContainer == false); + + //Here we need to figure out if the node is a container and if so check if the user has a custom start node, then check if that start node is a child + // of this container node. If that is true, the HasChildren must be true so that the tree node still renders even though this current node is a container/list view. + if (isContainer && UserStartNodes.Length > 0 && UserStartNodes.Contains(Constants.System.Root) == false) + { + var startNodes = Services.EntityService.GetAll(UmbracoObjectType, UserStartNodes); + //if any of these start nodes' parent is current, then we need to render children normally so we need to switch some logic and tell + // the UI that this node does have children and that it isn't a container + if (startNodes.Any(x => x.ParentId == e.Id)) + { + renderChildren = true; + } + } + + return renderChildren; + } + /// /// Before we make a call to get the tree nodes we have to check if they can actually be rendered /// @@ -290,7 +323,7 @@ namespace Umbraco.Web.Trees //before we get the children we need to see if this is a container node //test if the parent is a listview / container - if (current != null && current.IsContainer()) + if (current != null && ShouldRenderChildrenOfContainer(current) == false) { //no children! return new TreeNodeCollection();