Default value for child node?


is it possible to set a default value for a child node, e.g. main, when there is no value added yet? Just like defaultVaule for node properties? I’m thinking of something like:

    superTypes: ['TYPO3.Neos:Document']
        label: 'My Page'
            type: 'TYPO3.Neos:ContentCollection'
            defaultValue: 'No content yet'

Hey @kurztipp,

if you are asking for some default nodes within a content collection, this should not be possible right now.
There were some discussions and ideas about some kind of node templates.


yes I was asking exactly that. Thanks for the reply. Is there any possible workaround?

The following code won’t work because content.main's value are some Neos wrapper div tags. Also: Is it possible to check, wheter the page is rendered inside the backend?

#f:if inNeosBackend?
     <f:if condition="{content.main}">
          <div class="alert alert-info" role="alert">Write text here . . .</div>
      {content.main -> f:format.raw()}

I’m at least not aware of one. But you should read this:

Yeah, there are some viewhelpers to do that.

You can always count the children of main in typoscript and use that in the condition.


counting the children is a smart idea. To remove logic from the fluid themplate I tried it with TS. I managed to get it working for frontend:

main = TYPO3.Neos:ContentCollection {
    @if.onlyRenderWhenNotEmpty = ${q(node).children('main').children().count() > 0 }
    nodePath = 'main'

The problem is that this condition prevents rendering the contentCollection in backend, too. I would need something like

@if.onlyRenderWhenNotEmpty = ${q(node).children('main').children().count() > 0 }
@if.onlyRenderWhenNotEmpty.@if.onlyInFrontend = ${node.context.inBackend}

But this throws an exception. How can I combine the two conditions?

${(q(node).children('main').children().count() > 0) || node.context.inBackend}


the Typoscript

main = TYPO3.Neos:ContentCollection {
  @if.renderInBackendOrWhenNotEmpty = ${(q(node).children('main').children().count() > 0) || node.context.inBackend}
  nodePath = 'main'
  attributes.class = 'ui fluid container'
  attributes.class.@process.collectionClass >

doesn’t work my, unfortunately. main gets rendered in backend, but the children().count() condition seems to be wrong for frontend, because nothing gets rendered. What am I doing wrong?


It seems that ${node.context.inBackend} is empty or unset or whatsoever when not in backend and hence the condition doesn’t work.

backend = ${node.context.inBackend}


<p style="color:red">backend? {backend}</p>

renders to

<p style="color:red">backend? </p>

node.context.inBackend should be a boolean, I am not sure if Fluid will render that in any way. Try using it in an f:if condition to see if it works correctly.

Actually Fluid isn’t the problem. I mentioned this only for testing (Fluid seems to render true to 1 but false to an empty string). I don’t want main to be rendered when it doesn’t contain children, in order to avoid unused container tags in the output.

My problem is that main gets only rendered in backend although it contains children. I think I misunderstood something about the concept of @if or how to use it, because

c = 'yes'
c.@if.render = ${a || b}

outputs yes in a template which contains {c}

Your assumption about variables is wrong.

By assigning variables to a TypoScript object they are confined to that object but not available in the TypoScript context.


c = 'yes'
c.@if.render = ${this.a || this.b}

should work as intended as well as:

@context.a = FALSE
@context.b = FALSE
c = 'yes'
c.@if.render = ${a || b}

The question is why the original variant with two non existing variables does resolve to true. That might be a bug.