如何将流动页面模板中的值传递到 ext:mask 内容元素模板中?
How to pass a value from a fluid page template into a ext:mask content element template?
在带有 ext:mask 的 TYPO3 7 LTS 中,我想将一个值从我的页面模板传递到通过遮罩扩展呈现的 FLUIDTEMPLATE。
我正在努力实现的示例:
The content element has content that describes a car: A Volvo, 4WD...
In the page template, I want to display that "car" in different
colors. So the page template would be able to command: "get the first
car, and show it in green. Then the second car and show it in yellow".
(and no, it's got nothing to do with css..)
如果必须在整个页面上完成一次,我可以使用
`tt_content.default.mask_car.settings.color = green`
或者(备案)如果该变量的目的是修改演示文稿,我可以使用:
`tt_content.default.mask_car.settings.file = path/to/Mask/Content/Templates/car_green.html`
但是如果页面上有多个相同内容元素的实例,这种方法就不好了。
如何将不同的值传递给页面上同一 CE 的不同实例?
您可以添加以下 TypoScript:
lib.set_register = LOAD_REGISTER
lib.set_register.color = TEXT
lib.set_register.color.current = 1
lib.get_register.color = TEXT
lib.get_register.color.data = register:color
lib.mask_car < styles.content.get
lib.mask_car.select.where = colPos=123
并在页面模板中使用 Fluid
设置颜色
<f:cObject typoscriptObjectPath="lib.set_register.color" data="green"/>
使用 Fluid 获取您的内容元素
<f:cObject typoscriptObjectPath="lib.mask_car"/>
并使用 Fluid
切换遮罩模板中内容元素的输出
<f:if condition="{f:cObject(typoscriptObjectPath: 'lib.get_register.color')} == 'green'">
<f:then>
green
</f:then>
<f:else>
not green
</f:else>
</f:if>
希望本文能帮助您解决问题。
我遇到了类似的问题:
掩码内容元素的集合;同一页面上同一元素的两种不同呈现方式:
一个随机的 mask-ce 呈现为预告片,链接到页面底部的详细信息
呈现为列表项的所有蒙版 ce 的列表(详细信息)
我的解决方案:
随机预告片的渲染:
lib.qa_random_teaser_community < styles.content.get
lib.qa_random_teaser_community.select{
where = colPos=12
pidInList = {$pidCommunityQAStorage}
max = 1
orderBy = rand()
}
明细列表渲染:
lib.qa_list_community < styles.content.get
lib.qa_list_community{
renderObj < tt_content
renderObj.default.mask_qa_community.settings.renderListItems = 1
select {
where = colPos=12
pidInList = {$pidCommunityQAStorage}
}
}
我将tt_content复制到renderObj,然后我可以修改它,为mask元素添加专门的设置,只为这个内容渲染:
renderObj.default.mask_qa_community.settings.renderListItems = 1
在遮罩模板中,我只需检查设置并触发适当的渲染:
<f:if condition="{settings.renderListItems}">
<f:then>
<f:render section="qa-detail" arguments="{data:data}"/>
</f:then>
<f:else>
<f:render section="qa-teaser" arguments="{data:data}"/>
</f:else>
</f:if>
另一种方法是 select 专用的流体模板,而不是仅仅提供设置:
renderObj.default.mask_qa_community.settings.file = .......
在带有 TYPO3 8 的 Mask 3.0.1 中...
renderObj.mask_qa_community.settings.file = .......
希望它对其他人有用。
我正在重新审视这个问题,在带有掩码 4.x 的 TYPO3 9 中,这个有效:
lib.my_content_element {
renderObj.mask_content_text.settings.test = 123
}
在带有 ext:mask 的 TYPO3 7 LTS 中,我想将一个值从我的页面模板传递到通过遮罩扩展呈现的 FLUIDTEMPLATE。
我正在努力实现的示例:
The content element has content that describes a car: A Volvo, 4WD...
In the page template, I want to display that "car" in different colors. So the page template would be able to command: "get the first car, and show it in green. Then the second car and show it in yellow". (and no, it's got nothing to do with css..)
如果必须在整个页面上完成一次,我可以使用
`tt_content.default.mask_car.settings.color = green`
或者(备案)如果该变量的目的是修改演示文稿,我可以使用:
`tt_content.default.mask_car.settings.file = path/to/Mask/Content/Templates/car_green.html`
但是如果页面上有多个相同内容元素的实例,这种方法就不好了。
如何将不同的值传递给页面上同一 CE 的不同实例?
您可以添加以下 TypoScript:
lib.set_register = LOAD_REGISTER
lib.set_register.color = TEXT
lib.set_register.color.current = 1
lib.get_register.color = TEXT
lib.get_register.color.data = register:color
lib.mask_car < styles.content.get
lib.mask_car.select.where = colPos=123
并在页面模板中使用 Fluid
设置颜色<f:cObject typoscriptObjectPath="lib.set_register.color" data="green"/>
使用 Fluid 获取您的内容元素
<f:cObject typoscriptObjectPath="lib.mask_car"/>
并使用 Fluid
切换遮罩模板中内容元素的输出<f:if condition="{f:cObject(typoscriptObjectPath: 'lib.get_register.color')} == 'green'">
<f:then>
green
</f:then>
<f:else>
not green
</f:else>
</f:if>
希望本文能帮助您解决问题。
我遇到了类似的问题: 掩码内容元素的集合;同一页面上同一元素的两种不同呈现方式:
一个随机的 mask-ce 呈现为预告片,链接到页面底部的详细信息
呈现为列表项的所有蒙版 ce 的列表(详细信息)
我的解决方案:
随机预告片的渲染:
lib.qa_random_teaser_community < styles.content.get
lib.qa_random_teaser_community.select{
where = colPos=12
pidInList = {$pidCommunityQAStorage}
max = 1
orderBy = rand()
}
明细列表渲染:
lib.qa_list_community < styles.content.get
lib.qa_list_community{
renderObj < tt_content
renderObj.default.mask_qa_community.settings.renderListItems = 1
select {
where = colPos=12
pidInList = {$pidCommunityQAStorage}
}
}
我将tt_content复制到renderObj,然后我可以修改它,为mask元素添加专门的设置,只为这个内容渲染:
renderObj.default.mask_qa_community.settings.renderListItems = 1
在遮罩模板中,我只需检查设置并触发适当的渲染:
<f:if condition="{settings.renderListItems}">
<f:then>
<f:render section="qa-detail" arguments="{data:data}"/>
</f:then>
<f:else>
<f:render section="qa-teaser" arguments="{data:data}"/>
</f:else>
</f:if>
另一种方法是 select 专用的流体模板,而不是仅仅提供设置:
renderObj.default.mask_qa_community.settings.file = .......
在带有 TYPO3 8 的 Mask 3.0.1 中...
renderObj.mask_qa_community.settings.file = .......
希望它对其他人有用。
我正在重新审视这个问题,在带有掩码 4.x 的 TYPO3 9 中,这个有效:
lib.my_content_element {
renderObj.mask_content_text.settings.test = 123
}