diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js index 0f012810ba96..b2e6fa697681 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/contentpicker/contentpicker.controller.js @@ -238,11 +238,34 @@ function contentPickerController($scope, $q, $routeParams, $location, entityReso dialogOptions.startNodeId = -1; } else if ($scope.model.config.startNode.query) { - //if we have a query for the startnode, we will use that. - var rootId = $routeParams.id; - entityResource.getByQuery($scope.model.config.startNode.query, rootId, "Document").then(function (ent) { - dialogOptions.startNodeId = ($scope.model.config.idType === "udi" ? ent.udi : ent.id).toString(); - }); + + if ($routeParams.section === "content") { + var nodeId = $routeParams.id; + //if we have a query for the startnode, we will use that. + entityResource.getByQuery($scope.model.config.startNode.query, nodeId, "Document").then(function (ent) { + // ensure an entity is returned + if (ent) { + dialogOptions.startNodeId = ($scope.model.config.idType === "udi" ? ent.udi : ent.id).toString(); + } + }); + } + else { + // find content root nodes + entityResource.getChildren(-1, "Document").then(function (data) { + + // if only a single content node at root we can use that in XPath query + if (data && data.length === 1) { + var nodeId = data[0].id; + entityResource.getByQuery($scope.model.config.startNode.query, nodeId, "Document").then(function (ent) { + // ensure an entity is returned + if (ent) { + dialogOptions.startNodeId = ($scope.model.config.idType === "udi" ? ent.udi : ent.id).toString(); + } + }); + } + + }); + } } else { dialogOptions.startNodeId = $scope.model.config.startNode.id;