diff --git a/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php b/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php index 695f73ab566..8ac8f1c9751 100644 --- a/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php +++ b/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php @@ -68,14 +68,20 @@ public function initializeObject() /** * Render a node label based on an eel expression or return the expression if it is not valid eel. * - * @param \Neos\ContentRepository\Domain\Projection\Content\NodeInterface $node - * @return string * @throws \Neos\Eel\Exception */ public function getLabel(\Neos\ContentRepository\Domain\Projection\Content\NodeInterface $node): string { - if (Utility::parseEelExpression($this->getExpression()) === null) { - return $this->getExpression(); + $expression = $this->getExpression(); + if ($node->isAutoCreated()) { + $parentNode = $node->getParent(); + $property = 'childNodes.' . $node->getName() . '.label'; + if ($parentNode?->getNodeType()->hasConfiguration($property)) { + $expression = $parentNode->getNodeType()->getConfiguration($property); + } + } + if (Utility::parseEelExpression($expression) === null) { + return $expression; } return (string)Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, ['node' => $node], $this->defaultContextConfiguration); } diff --git a/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml b/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml index 56362f49579..28a7aafda62 100644 --- a/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml +++ b/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml @@ -205,3 +205,13 @@ 'Neos.ContentRepository.Testing:NodeTypeWithEelExpressionLabel': label: '${"Test" + " " + "nodetype"}' + +'Neos.ContentRepository.Testing:NodeTypeWithPlainLabelInChildNode': + childNodes: + child: + label: 'Test child node' + +'Neos.ContentRepository.Testing:NodeTypeWithEelExpressionLabelInChildNode': + childNodes: + child: + label: '${"Test" + " child " + "node"}' diff --git a/Neos.ContentRepository/Resources/Private/Schema/NodeTypes.schema.yaml b/Neos.ContentRepository/Resources/Private/Schema/NodeTypes.schema.yaml index 1903649845f..d06800baee1 100644 --- a/Neos.ContentRepository/Resources/Private/Schema/NodeTypes.schema.yaml +++ b/Neos.ContentRepository/Resources/Private/Schema/NodeTypes.schema.yaml @@ -19,7 +19,7 @@ additionalProperties: 'label': type: ['string', 'array'] - description: "An EEL expression for generating a node's of this node type's label. Alternatively an array with the key generatorClass and optional options." + description: "An EEL expression for generating a node's of this node type's label. Alternatively an array with the key generatorClass and optional generator options." 'constraints': &constraints type: dictionary @@ -42,6 +42,7 @@ additionalProperties: type: dictionary additionalProperties: false properties: + 'label': { type: string, description: "A string or an EEL expression for generating a node's of this node type's label. Alternatively an array with the key generatorClass and optional generator options." } 'type': { type: string, description: "Node Type of this child node." } 'position': type: ['string', 'null'] diff --git a/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php b/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php index 8c7d3288e85..e173472a921 100644 --- a/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php +++ b/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php @@ -1077,6 +1077,23 @@ public function getLabelReturnsParsedEelExpressionOrFallback() self::assertEquals('Test nodetype', $nodeWithEelExpressionLabel->getLabel()); } + /** + * @test + */ + public function getChildNodeLabelReturnsParsedEelExpressionOrFallback() + { + $nodeTypeManager = $this->objectManager->get(NodeTypeManager::class); + $nodeTypeWithPlainLabelInChildNode = $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithPlainLabelInChildNode'); + $nodeTypeWithEelExpressionLabelInChildNode = $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithEelExpressionLabelInChildNode'); + + $rootNode = $this->context->getNode('/'); + $nodeWithPlainLabelInChildNode = $rootNode->createNode('node-plain', $nodeTypeWithPlainLabelInChildNode, '30e893c1-caef-0ca5-b53d-e5699bb8e506'); + $nodeWithEelExpressionLabelInChildNode = $rootNode->createNode('node-eel', $nodeTypeWithEelExpressionLabelInChildNode, '81c848ed-abb5-7608-a5db-7eea0331ccfa'); + + self::assertEquals('Test child node', $nodeWithPlainLabelInChildNode->getLabel()); + self::assertEquals('Test child node', $nodeWithEelExpressionLabelInChildNode->getLabel()); + } + /** * @test */ diff --git a/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/FourColumn.yaml b/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/FourColumn.yaml index de418826c7c..d33defa0fcb 100644 --- a/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/FourColumn.yaml +++ b/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/FourColumn.yaml @@ -6,12 +6,16 @@ position: 400 childNodes: column0: + label: 'Left Column' type: 'Neos.Neos:ContentCollection' column1: + label: 'Middle Left Column' type: 'Neos.Neos:ContentCollection' column2: + label: 'Middle Right Column' type: 'Neos.Neos:ContentCollection' column3: + label: 'Right Column' type: 'Neos.Neos:ContentCollection' properties: layout: diff --git a/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/ThreeColumn.yaml b/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/ThreeColumn.yaml index 0c540412f7f..9e03bdabfe6 100644 --- a/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/ThreeColumn.yaml +++ b/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/ThreeColumn.yaml @@ -6,10 +6,13 @@ position: 300 childNodes: column0: + label: 'Left Column' type: 'Neos.Neos:ContentCollection' column1: + label: 'Middle Column' type: 'Neos.Neos:ContentCollection' column2: + label: 'Right Column' type: 'Neos.Neos:ContentCollection' properties: layout: diff --git a/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/TwoColumn.yaml b/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/TwoColumn.yaml index b64b2eb78f2..27a461d6b9e 100644 --- a/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/TwoColumn.yaml +++ b/Neos.NodeTypes.ColumnLayouts/NodeTypes/Content/TwoColumn.yaml @@ -6,8 +6,10 @@ position: 200 childNodes: column0: + label: 'Left Column' type: 'Neos.Neos:ContentCollection' column1: + label: 'Right Column' type: 'Neos.Neos:ContentCollection' properties: layout: