[英]Fusion (Typoscript 2): How to access a variable from a parent object?
This is sort of a follow-up question for How to define and access local variable in Typoscript 2 (Neos)? 这是有关如何在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
? 如果在下面的示例中定义了一个名为
myLocalVar
的局部变量, myLocalVar
如何从其他对象(在本例中为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
? 在此具体示例中:如何从
Neos.Fusion:Matcher
内部访问myLocalVar
?
The part in question is the condition: condition = ${???.myLocalVar[0] == 'aaa'}
有问题的部分是条件:
condition = ${???.myLocalVar[0] == 'aaa'}
You need to define your myLocalVar as context variable: 您需要将myLocalVar定义为上下文变量:
@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'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.