Default title for NodeType


(Florian Feuerpfeil) #1

Hello,

is there a method to set a default title to a nodetype like the timestamp or so?

properties:
  title:
    defaultValue: ‘something’

did not work.
I’m also searching for thomething like : defaultValue: now

Is this possible?

Thanks for your response.

p.s. the Type should be a Page.


(Daniel Lienert) #2

Hey Florian,

with https://github.com/Flowpack/Flowpack.NodeTemplates you are able to use Eel queries to define properties on creation including a formatted date.

Cheers.
Daniel


(Florian Feuerpfeil) #3

Hi Daniel,

thanks for response but my task is still open.
With the Template am able to define some default stuff for the creation dialog. But I’m not able to find a solution where I can set an defaultValue for the titel of the Node itself.

creationDialog:
  elements:
    title:
      type: 'Neos.NodeTypes:Text'
      properties:
        text: '${"<p>Dummy</p>"}'
      ui:
        label: 'Titel'
        editorOptions:
          placeholder: 'test'
          values: 'testvalue'

I try some test with or without type or or or. Is anyone able to give me another tip?

Thanks Florian


(Benjamin Klix) #4

I’m not totally sure, what you want to achieve.

You can change the displayed title (in the structure tree) by changing the label in the NodeType Definition. The default is defined like this (i removed some parts for better readability):

'Neos.Neos:Node':
  label: "${q(node).property('title') || q(node).property('text') || 'Node'}"

See NodeTypes.yaml in Neos.Neos package.

If you want to set a default value for properties, you simply can set it that way:

'Your.Package:NodeType':
  properties:
    title:
      type: 'string'
      defaultValue: 'Your default value here'

If you want to use a default value in the creation dialog: I’m not sure if this works. Maybe @dimaip can tell you if that works.

If you want to set the default values of a child node, you need to use the package posted by @daniellienert or extend another nodetype and update the defaultValue.

Hope this helps you a little.