How to define and access local variable in Typoscr

2019-09-08 06:19发布

I have created a custom NodeType "Events" with a custom TS2 file in Neos, but I guess it is more a general question about Typoscript 2.

prototype(Some.Namespace:Events) < prototype(TYPO3.Neos:Document) {
    ...

    sortOrder = ${request.arguments.sortOrder  == 'asc' ? 'asc' : 'desc'}
    otherVariable = ${sortOrder}

    ...
}

Of course this is simplified to focus on the issue:

I want to assign the value of the variable sortOrder (which is "asc" or "desc") to another variable named otherVariable.

How can I do that? I cannot access the value using ${sortOrder}, which returns always NULL.

1条回答
\"骚年 ilove
2楼-- · 2019-09-08 06:38

All you need to do is add this as below and {otherVariable} in your fluid template will work. Flush cache in case you sill have NULL.

sortOrder = ${request.arguments.sortOrder  == 'asc' ? 'asc' : 'desc'}
otherVariable = ${this.sortOrder}
查看更多
登录 后发表回答