[英]How to use typoscript object in fluid template as if condition
I have a typoscript TEXT object: 我有一个拼写文字对象:
lib.myid = TEXT
lib.myid.value = 1413
And want to use it in a fluid template (for tx_news): 并想在流畅的模板中使用它(用于tx_news):
<f:for each="{newsItem.categories}" as="category">
<f:if condition="{category.uid} == {lib.myid}">
Category ID is the same as myid
</f:if>
</f:for>
How can I do this? 我怎样才能做到这一点?
You can use the ViewHelper f:cObject . 您可以使用ViewHelper f:cObject 。 It would look like this:
它看起来像这样:
<f:for each="{newsItem.categories}" as="category">
<f:if condition="{category.uid} == {f:cObject(typoscriptObjectPath: 'lib.myid')}">
Category ID is the same as myid
</f:if>
</f:for>
Alternatively, you can make the value a setting of the news plugin, by setting 或者,您可以通过将值设置为新闻插件的设置
plugin.tx_news {
settings {
valuefromlibrary < lib.myid
}
}
Afterwards, you can access the value using {settings.valuefromlibrary}
in your template. 之后,您可以使用模板中的
{settings.valuefromlibrary}
访问该值。 But beware that the settings are not automatically passed on to partials, so in a partial the value might not be defined. 但是请注意,设置不会自动传递到局部文件,因此在局部文件中,可能未定义该值。 This restriction is circumvented in the default template of EXT:news by passing the
settings
-variable to partials. 通过将
settings
-variable传递给partials,可以在默认模板EXT:news中规避此限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.