[英]TYPO3: How can I access property of objects in a partial or section?
I have an object defined in TypoScript 我在TypoScript中定义了一个对象
page.10 {
variables {
myObject = COA
myObject{
1 = TEXT
1.value = yome Text
2 = TEXT
2.value = 42
}
}
}
and I need the data of the myObject in a partial 我需要部分中myObject的数据
<f:render partial="myPartial" arguments="{content:myObject}" />
that looks like 看起来像
<section id="myPartial">
<h2>{content.1}</h2>
<p>{content.2}</p>
</section>
Although the content is there ( because {content} will display all the properties) I cannot access it and h2 and p will be empty... 尽管内容在那里(因为{content}将显示所有属性),但我无法访问它,并且h2和p将为空...
What should I do to fill h2 and p with the content of myObject? 我该怎么做才能用myObject的内容填充h2和p?
That is not possible. 这是不可能的。
TypoScript
only returns text strings at the moment, not arrays. TypoScript
仅返回文本字符串,而不返回数组。 Thus the variable myObject
contains the whole concatenated string of the COA
, thus yome Text42
. 因此,变量
myObject
包含COA
的整个串联字符串,因此yome Text42
。
Note that COA
means Content Object Array
, but the whole COA
is one single object that is returned as one string. 需要注意的是
COA
意味着Content Object Array
,但整体COA
是返回作为一个字符串一个单独的对象。
Alternative: use the VHS
extension's v:var.typoscript
ViewHelper: 备选方案:使用
VHS
扩展的v:var.typoscript
ViewHelper:
{namespace v=Tx_Vhs_ViewHelpers} {v:var.typoscript(path: 'page.10.variables.myObject') -> v:var.set(name: 'myObject')}
After which you can access {myObject.1}
etc. in your template. 之后,您可以在模板中访问
{myObject.1}
等。 Note that the so-called "chained" usage of v:var.set
is optional , but will make it easier to access your variables using an intermediate template variable instead of more expensive calls to retrieve the value completely in multiple locations . 请注意,
v:var.set
的所谓“链接”用法是可选的 , 但是它将使使用中间模板变量访问变量变得更容易,而不是使用昂贵的调用来在多个位置完全检索值 。 The other way: 另一种方法:
{v:var.typoscript(path: 'page.10.variables.myObject.1')} {v:var.typoscript(path: 'page.10.variables.myObject.2')} etc.
VHS extension on TER: http://typo3.org/extensions/repository/view/vhs TER上的VHS扩展: http : //typo3.org/extensions/repository/view/vhs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.