Fusion (Typoscript 2): How to access a variable fr

2019-07-27 10:59发布

This is sort of a follow-up question for How to define and access local variable in Typoscript 2 (Neos)?

If I define a local variable, called myLocalVar in the example below, how can I access it from other objects, in this case from Neos.Fusion:Case?

prototype(Some.Namespace:SomeNodeType) < prototype(TYPO3.Neos:Content) {
    myLocalVar = ${String.split(q(node).property('example'), '/', 2)}

    myResult = Neos.Fusion:Case {
        a = Neos.Fusion:Matcher {
            condition = ${???.myLocalVar[0] == 'aaa'}
            renderer = 'first part is aaa'
        }
        b = Neos.Fusion:Matcher {
            condition = ${???.myLocalVar[0] == 'bbb'}
            renderer = 'first part is bbb'
        }
    }
}

In this concrete example: How can I access myLocalVar from inside Neos.Fusion:Matcher?

The part in question is the condition: condition = ${???.myLocalVar[0] == 'aaa'}

1条回答
\"骚年 ilove
2楼-- · 2019-07-27 11:36

You need to define your myLocalVar as context variable:

@context.myLocalVar = ${String.split(q(node).property('example'), '/', 2)}

the context is inherited by all nesting objects, so you can just access the value like this

a = Neos.Fusion:Matcher {
    condition = ${myLocalVar[0] == 'aaa'}
    renderer = 'first part is aaa'
}
查看更多
登录 后发表回答