在模板中访问流体页面配置 [英] Access fluidpage configuration in template
问题描述
我正在尝试访问模板内的流体页面配置.
I'm trying to access fluid page configuration inside a template.
详细说明:我在页面布局中添加了一个选择字段
In detail: I added a selectfield to my page layout
<flux:flexform.field.select name="pageIcon" items="{
0: {0: '{f:translate(key: \'pageIconNone\')}', 1: ''},
1: {0: '{f:translate(key: \'pageIconFacebook\')}', 1: 'fa-facebook-square'},
2: {0: '{f:translate(key: \'pageIconFlickr\')}', 1: 'fa-flickr'},
3: {0: '{f:translate(key: \'pageIconGooglePlus\')}', 1: 'fa-google-plus-square'}
}"/>
到目前为止一切顺利.现在我渲染一个菜单,想要访问这个字段 pageIcon
So far so good. Now I render a menu an want to access this field pageIcon
<v:page.menu.directory pages="{settings.pid.socialMenu}" useShortcutData="TRUE" classFirst="first" classLast="last">
<f:for each="{menu}" as="mainPage" iteration="iteration">
<a href="{mainPage.link}" class="{mainPage.class}"><i class="fa {mainPage.pageIcon} fa-2x"></i><b>{mainPage.title}</b></a>
</f:for>
</v:page.menu.directory>
但这行不通.经过一些调试,我注意到,这个配置似乎存储在 tx_fed_page_flexform 中,其中包含一个 XML 数组.
But this does not work. After some debugging I noticed, that this configuration seems to be stored in tx_fed_page_flexform which holds an XML array.
如何访问流体模板中的 XML 值?
How can I access the XML values inside my fluid template?
马库斯
推荐答案
最简单的方法:
https://fluidtypo3.org/viewhelpers/flux/master/Form/DataViewHelper.html
不总是提取这些数据的原因仅仅是为了性能.还有一种你可能不知道的方式:
The reason for not extracting this data always, is simply for performance. There is another way which you may not be aware of:
如果您这样命名您的字段(pages.
前缀是关键,因为我们使用的是 pages
DB 表)您的值将保存到记录本身(您必须在 SQL 模式/TCA 中添加一个字段,如果需要,可以在根行中启用值滑动).如果保存了具有此前缀的字段,Flux 将直接将其值插入到页面记录中,这意味着您可以使用例如 {pageVariable.icon}
立即访问它,而无需 flux:flexform.data
ViewHelper.
If you name your field thusly (the pages.
prefix is the key since we are using the pages
DB table) your value will be saved into a field in the record itself (a field you must then add in the SQL schema / TCA, and enable value sliding in the rootline if you desire it). If a field with this prefix is saved, Flux will insert its value directly into the pages record which means you can immediately access it using for example {pageVariable.icon}
without the need for the flux:flexform.data
ViewHelper.
对于 Flux 的更新版本,请尝试:
For more recent version of Flux, try:
这篇关于在模板中访问流体页面配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!