Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Custom label for auto created child nodes #530

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

dfeyer
Copy link
Contributor

@dfeyer dfeyer commented May 19, 2016

Resolves: #2276

This change add a node type configuration to generate a custom node label
for auto created child nodes:

'Neos.Neos.NodeTypes:Page':
  superTypes:
    'Neos.Neos:Document': TRUE
  childNodes:
    main:
      label: 'Main Content Collection'
      type: 'Neos.Neos:ContentCollection'

This allow to have a less technical content tree. This change include the
schema validation and default label for default node types.

The label can be a string or an EEL expression. Inside the
expression you can access the parent node in the variable parentNode.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @radmiraal, @skurfuerst and @aertmann to be potential reviewers

@dfeyer
Copy link
Contributor Author

dfeyer commented May 19, 2016

Pretty useful for ContentCollection to replace "Content Collection (footer)", by something more human readable like "Document Footer". Also useful with complex node type with multiple child node, like a Staff, with multiple PostalAddress and ContactInformation, ...)

@@ -71,13 +74,27 @@ public function initializeObject()
*/
public function getLabel(NodeInterface $node, $crop = true)
{
$label = \TYPO3\Eel\Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, array('node' => $node), $this->defaultContextConfiguration);
$label = null;
if ($node->getNodeType()->isOfType('TYPO3.Neos:ContentCollection') && $node->isAutoCreated()) {
Copy link
Member

@kitsunet kitsunet May 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a no-go as it introduces a semi dependency of Neos in CR. If we want to introduce this kind of feature it must work for all node types.
I could accept that and I can see how nice this can look like, but I am not 100% sold for this yet...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but why does it even need to only be for content collections? isn't the fact that it's auto-created and has the label property set enough?

@kitsunet
Copy link
Member

See inline comment 👎 for now

$parentNode = $node->getParent();
$property = 'childNodes.' . $node->getName() . '.label';
if ($parentNode->getNodeType()->hasConfiguration($property)) {
$expression = $parentNode->getNodeType()->getConfiguration($property);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if this also accepted simple strings and not only expressions, since that's unnecessary most of the time

@aertmann
Copy link
Contributor

aertmann commented May 20, 2016

Nice idea, I think we can make it work.. see inline comments

It's missing documentation as well though

@aertmann aertmann changed the title FEATURE: Add custom label for auto created child node FEATURE: Custom label for auto created child nodes May 20, 2016
@dfeyer
Copy link
Contributor Author

dfeyer commented Jul 11, 2016

@aertmann @kitsunet Now support string, and no dependency to the ContentCollection anymore, it's pretty generic and useful.

As discussed with @kitsunet last week, we need to take to not have too much configuration that can depend on the "context" (parent node, ...) or we will have hard time to debug it.

Next step a small documentation and this one is merge ready

@dfeyer dfeyer removed the I: WIP label Jul 11, 2016
@dfeyer
Copy link
Contributor Author

dfeyer commented Nov 3, 2016

Up to date with master and update the first PR comment to show the possibility to use a string or EEL expression as label.

@kitsunet
Copy link
Member

👍 Shoudl be fine!

@dfeyer
Copy link
Contributor Author

dfeyer commented Nov 10, 2016

@aertmann If you can review again we can merge this one

@dfeyer
Copy link
Contributor Author

dfeyer commented Dec 5, 2017

@aertmann @kitsunet Maybe this can finaly be merged ;)

@@ -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 options." }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe more specific "and optional generator options."

*/
public function getLabel(NodeInterface $node)
{
$label = Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, array('node' => $node), $this->defaultContextConfiguration);
$label = null;
if ($node->getNodeType()->isOfType('TYPO3.Neos:ContentCollection') && $node->isAutoCreated()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this limitation on only ContentCollection?

@dfeyer
Copy link
Contributor Author

dfeyer commented Dec 5, 2017

Thanks @aertmann for the review, all comments fixed

Copy link
Contributor

@aertmann aertmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤗

@kitsunet
Copy link
Member

I re-read the code and from a user perspective this is great, but I am still not convinced about the implementation. That's a lot of logic in the LabelGenerator that any person implementing the interface would have to replicate. Also The LabelGenerator shouldn't be in charge of figuring this out. If we want to do this, we might want to change the interface to tell the generator where to get the config from maybe.

@dfeyer
Copy link
Contributor Author

dfeyer commented May 8, 2018

@kitsunet What if we introduce an Abstract class with helper function, and a protected method to override the label for the automaticaly created child nodes ? Like this custom implementation can reuse the abstract class and we avoid changing the interface ?

@dfeyer
Copy link
Contributor Author

dfeyer commented May 8, 2018

And maybe a missing feature is the support of i18n keywords to have translatable labels ...

@kdambekalns
Copy link
Member

This looks really useful, so could you (@dfeyer and @kitsunet) decide on a path forward? Thanks!

@jonnitto jonnitto requested a review from kitsunet November 6, 2018 16:08
@mhsdesign mhsdesign marked this pull request as draft February 8, 2024 19:30
@mhsdesign mhsdesign changed the base branch from 8.2 to 7.3 February 8, 2024 19:31
@github-actions github-actions bot added the 7.3 label Feb 8, 2024
@Sebobo Sebobo self-requested a review July 27, 2024 06:04
@Sebobo Sebobo self-assigned this Jul 27, 2024
@Sebobo Sebobo added 8.4 and removed 7.3 labels Jul 27, 2024
@Sebobo
Copy link
Member

Sebobo commented Jul 27, 2024

I would like to try to bring this into 8.4 as recently I was sad again in two projects that the feature doesn't exist yet and I had to introduce ContentCollection subtypes for no further reason than to have proper labels.

@Sebobo Sebobo force-pushed the feature-custom-child-node-label branch from 2a9c67e to 4a06cce Compare July 27, 2024 06:50
@Sebobo Sebobo changed the base branch from 7.3 to 8.4 July 27, 2024 06:51
@github-actions github-actions bot added 7.3 and removed 7.3 labels Jul 27, 2024
@Sebobo Sebobo force-pushed the feature-custom-child-node-label branch from 4a06cce to 3b9ec37 Compare July 27, 2024 06:52
This change add a node type configuration to generate a custom node label
for auto created child nodes:

    ‚Neos.NodeTypes:Page':
      superTypes:
        ‚Neos.Neos:Document': TRUE
      childNodes:
        main:
          label: ‚Main Content Collection'
          type: ‚Neos.Neos:ContentCollection'

This allow to have a less technical content tree. This change include the
schema validation and default label for default node types.
@Sebobo Sebobo force-pushed the feature-custom-child-node-label branch from 3b9ec37 to 2e7c49e Compare July 27, 2024 06:54
@Sebobo Sebobo marked this pull request as ready for review July 27, 2024 07:08
@Sebobo Sebobo requested review from ahaeslich and pKallert July 27, 2024 07:35
@Sebobo Sebobo requested review from mhsdesign and dlubitz August 13, 2024 09:41
Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha nice thanks for the restoration of this pr ^^
Would be great if you could create an upmerged version of this for Neos 9 as well (there we have different tests and the class was moved and the api changed ...)

@Sebobo Sebobo merged commit ed79f5f into neos:8.4 Aug 13, 2024
4 of 6 checks passed
@dlubitz
Copy link
Contributor

dlubitz commented Sep 6, 2024

@Sebobo This change has not been upmerged to Neos 9, as this will not work there anymore. Please provide a dedicated PR to 9.0 if this feature is also needed there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants