How to access a defined value of a page node from within another page node

Hi,

I’d like to access the first TYPO3.Neos.NodeTypes:Text of some page nodes as some kind of preview in another page. I can select the pages I want to display.

category < page
category {
    
    body {
        . . .
        posts = ${q(node).children('[instanceof My.Page:Article]')}
    }
}

And I can select the node I want to display.

article < page
article {
  . . .

    body {
       . . .
        teaserText = ${q(node).find('main').children('[instanceof TYPO3.Neos.NodeTypes:Text]').first().property('text')}
  }
}

But how can I access the value of teaserText from within the template?

      <f:for each="{posts}" as="post">
        . . .
        <div class="content">{ ? post.teaserText ? -> f:format.raw()}</div>
        . . .
      </f:for>

The above doesn’t display anything. I tried {post -> f:debug()} but that doesn’t show teaserText as a child of post. How do I access the node?

```post.properties.teaserTextor in TypoScript using.property(‘teaserText’)`

Hi,

teaserText isn’t a property of post as it isn’t defined in NodesTypes.yaml. So, post.properties.teaserText yields NULL.

I want to use the first TextNode in my article pages as teaser text. So I’m using find()to get the first TextNode in my Article.ts2 and store it in teaserText. The categories show every article page that is their child. So, I need access to teaserText from my Category Fluid template. But I don’t know how, if it’s no property which are accessible via properties.

There are two approaches …

  1. Make the teaserText text a property of the ArticleNode. I would consider it good practice to display it on the document and make it inline editable aswell so editors can edit it like any other text. That often works well as a leading text between Header and main content.

  2. Use a <ts:render path=“{ArticleNodeTextRenderer}” context=“{articleNode:articleNode}”> to render the text of every node and inside try to use a flow query like this

articleNodeTextRenderer = TYPO3.TypoScript:Value {
    value = ${q(articleNode).children('main').children('[instanceof TYPO3.NeosNodeTypes:Text]').property('text')}
}

Notice that i use the children-operation instead of find because this will only search directly below the selected node. The flowQuery will find all TextNodes in the main collection but the property operation will only return the value of the property in the firstNode of the collection.

*Attention i did’nt try the code above so beware of typos