【发布时间】:2021-07-16 04:22:06
【问题描述】:
这和我的问题Counter for mask elements in a TYPO3 column非常相似
我需要将一个变量(在我的例子中,cObj:parentRecordNumber 的值,它是其列中当前项目的计数器)传递给模板。
在主页模板中:
<f:cObject typoscriptObjectPath="lib.content.pageteasers" />
在排版中:
lib.content {
pageteasers < styles.content.get
pageteasers {
select {
where = colPos=2
max = 8
}
// this passes the variable elementCounter to the fluid template of the rendered mask content element:
renderObj.mask_teaser {
variables {
elementCounter = TEXT
elementCounter.value = {cObj:parentRecordNumber}
elementCounter.insertData = 1
}
}
// this should pass the same value to a rendered tx_news plugin:
variables {
elementCounter = TEXT
elementCounter.value = {cObj:parentRecordNumber}
elementCounter.insertData = 1
}
// it doesn't. what about these trial & error:
renderObj.list < .variables
renderObj.plugin.tx_news < .variables
renderObj.list.20.news_pi1 < .variables
renderObj.news_pi1 < .variables
// none of these seem to work either
}
}
然后在渲染的 CE 模板中 (News/List.html)
<f:debug title="" inline="1">{_all}</f:debug>
我在这里看不到上面的变量。将变量从 TS 传递到新闻流模板的正确方法是什么?
PS 另一个尝试是使用 Good Old Register
pageteasers < styles.content.get
pageteasers {
select {
where = colPos=2
max = 8
}
append = LOAD_REGISTER
append {
elementCounter = TEXT
elementCounter.value = {cObj:parentRecordNumber}
elementCounter.insertData = 1
}
}
在模板中:
{v:variable.register.get(name: 'elementCounter')}
但那是NULL
【问题讨论】:
-
您的 sn-p 适用于 cType "FLUIDTEMPLATE" 的 CE。插件属于“USER/USER_INT”类型,并且(通常)不具有“变量”属性。
-
是否有与插件“通信”的解决方法?
-
但是插件最终使用了 FLUIDTEMPLATE,不是吗?我不能以某种方式解决它吗?
-
插件使用流体模板,是的。但它不通过变量。不要混淆 Fluid-Template (=> HTML) 和 FLUIDTEMPLATE-cObject (=> TypoScript)。在您的情况下(显示 cObject 的值),无需通过变量将其传递到模板中。 cObject-Viewhelper 应该解决这个问题:docs.typo3.org/other/typo3/view-helper-reference/10.4/en-us/…
-
谢谢朱利安。不过,我不确定如何解释您的解决方案建议。你能举个例子作为答案吗?
cObj:parentRecordNumber默认在内容对象中不可用。
标签: typo3 typoscript fluid tx-news typo3-10.x