[Neos] Help with some typoscript

Aske Ertmann aske at moc.net
Tue Feb 4 18:31:24 CET 2014


Hey Nick

Just had a quick look at it and it looks like you’re not specifying which property from the Headline and Text element you want to slice. You only get the actual node.

I think it should be something like:
teaserHeadline = ${q(teaserTargetNode).children('column0').children('[instanceof TYPO3.Neos.NodeTypes:Headline]').first().get(0).property(’title’)} or without the .get(0) can’t remember

teaserText= ${q(teaserTargetNode).children('column0').children('[instanceof TYPO3.Neos.NodeTypes:Text]').first().property(’text’)} again .get(0) or not here..

I’d also suggest that you make use of Fluid when cropping the text instead of the slice helper since it doesn’t have nice features like adding an ellipsis if cropped or respect for html tags.

<f:if condition=“{teaserHeadline}”><f:then>{teaserHeadline}</f:then><f:else>{teaserText -> f:format.crop(maxCharacters: 400)}</f:else></f:if>

/Aske

On 04/02/2014, at 13.52, Nick <nick at jamalade.com> wrote:

> Hi all
> 
> I am trying to implement a teaser nodetype which I have called SectionTeaser which can be used to create a teaser element for a Section.
> The idea would be that the editor inserts a SectionTeaser and then selects a node of type Section. Then I want to grab the Section and display the sections Headline, if it exists, and say the first 400 characters of the section's first text element.
> I have defined:
> Reroot.RerootSiteCom:Section to be a subtype of TYPO3.Neos:Content and have childNodes column0 with type TYPO3.Neos:Content.
> Reroot.RerootSiteCom:SectionTeaser is a subtype of TYPO3.Neos:Content and has one property teaserTargetNode type reference with an editor option nodetypes : Reroot.RerootSiteCom:Section.
> 
> 
> When it comes to the TypoScript I seem to be getting nowhere, which is probably a reflection of my knowledge :(
> 
> I had hoped in SectionTeaser.ts2 to try something like this:
> 
> prototype(Reroot.RerootSiteCom:SectionTeaser) < prototype(TYPO3.Neos:Content){
>    templatePath = 'resource://Reroot.RerootSiteCom/Private/Templates/NodeTypes/SectionTeaser.html'
> 
>    // get the Target Node for this teaser
>    teaserTargetNode = ${q(node).property('teaserTargetNode')}
> 
>    //search for the first (there could be more than one ) TYPO3.Neos.NodeTypes:Headline contend in the childNode 'column0'
>    teaserHeadline = ${q(teaserTargetNode).children('column0').children('[instanceof TYPO3.Neos.NodeTypes:Headline]').first().get(0)}
> 
>    //grab the first 400 chars of the first TYPO3.Neos.NodeTypes:Text contained in the Section
>    teaserText= ${q(teaserTargetNode).children('column0').children('[instanceof TYPO3.Neos.NodeTypes:Text]').first().slice(0,400)}
> }
> 
> I would then render teaserHeadline and teaserHeadline in the SectionTeaser.html
> 
> However they are always empty.
> 
> Any pointers would be gratefully appreciated
> 
> Best wishes
> 
> Nick
> 
> 
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos



More information about the Neos mailing list