Typo3 流体模板中页面记录的访问关系
我目前正在用TYPO3构建一个扩展,它确实通过另一个字段扩展了TYPO3核心的Typo3 流体模板中页面记录的访问关系,typo3,fluid,typo3-7.6.x,Typo3,Fluid,Typo3 7.6.x,我目前正在用TYPO3构建一个扩展,它确实通过另一个字段扩展了TYPO3核心的pages表 我的问题描述: 该字段与我自己的记录是MM关系,包含描述、一些图像等。。。 因为我的扩展没有提供自己的插件(它是一个通用的站点扩展,提供站点模板等等),所以我必须通过fluid template访问页面记录的新字段。 但是,通过访问pages info数组中的此字段(使用或{data.myfield}),我只获得引用行的当前计数(pages记录中数据库列的值) 因此,我的问题是: 如何访问流体模板中该附
pages
表
我的问题描述:
该字段与我自己的记录是MM关系,包含描述、一些图像等。。。
因为我的扩展没有提供自己的插件(它是一个通用的站点扩展,提供站点模板等等),所以我必须通过fluid template访问页面
记录的新字段。
但是,通过访问pages info数组中的此字段(使用
或{data.myfield}
),我只获得引用行的当前计数(pages记录中数据库列的值)
因此,我的问题是:
- 如何访问流体模板中该附加字段的内容,迫使TYPO3识别从MM表到引用记录的跳转?通常的“打字方式”是什么
- 或者我必须编写自己的ViewHelper来获取两条记录之间的引用吗
- 是否有任何打字解决方案
$temporaryColumns=数组(
“tx\u user\u myext\u myfield”=>数组(
/*…这里有一些较小的不重要的TCA设置*/
'配置'=>数组(
'类型'=>'组',
“内部类型”=>“db”,
'allowed'=>'tx\u user\u myext\u mycustomrow',
“外部表格”=>“tx\U用户\U myext\U mycustomrow”,
'MM'=>'tx\U用户\U myext\U mycustomrow\U页面\U MM',
“MM_hasUidField”=>1,
“多个”=>1
)
)
);
(当然,我将$temporaryColumns
传递给addTCAcolumns
和addToAllTCAtypes
。后端功能工作正常-这不是问题。)
编辑:我无法为此构建插件,因为它是网站的一个通用部分。(因此,它将在模板中解决。)只有记录关系应由用户更改
我希望你能帮助我;非常感谢您对这个问题的回复。最好的方法是扩展/创建页面模型,并创建一个插件来显示您的内容 也可以用打字稿来完成
myRecords = CONTENT
myRecords {
table = tx_user_myext_mycustomrow
select {
pidInList = root,-1
selectFields = tx_user_myext_mycustomrow.*
join = tx_user_myext_mycustomrow_pages_MM ON tx_user_myext_mycustomrow_pages_MM.uid_local = tx_user_myext_mycustomrow.uid
where.data = field:_ORIG_uid // field:uid
where.intval = 1
where.wrap = tx_user_myext_mycustomrow_pages_MM.uid_foreign=|
orderBy = tx_user_myext_mycustomrow_pages_MM.sorting_foreign
}
renderObj = COA
renderObj.10 = TEXT
renderObj.10.field = somefield
renderObj.10.wrap = <h1>|</h1>
}
# add myRecords to your fluid variables. I assume that the fluidtemplate is in page.10
page.10.variables.myRecords < myRecords
myRecords=CONTENT
我的记录{
table=tx\u user\u myext\u mycustomrow
挑选{
pidInList=根,-1
选择fields=tx\u user\u myext\u mycustomrow*
join=tx\u user\u myext\u mycustomrow\u pages\u MM ON tx\u user\u myext\u mycustomrow\u pages\u MM.uid\u local=tx\u user\u myext\u mycustomrow.uid
其中.data=field:\u ORIG\u uid//field:uid
其中,intval=1
其中.wrap=tx\u user\u myext\u mycustomrow\u pages\u MM.uid\u foreign=|
orderBy=tx\u user\u myext\u mycustomrow\u pages\u MM.sorting\u foreign
}
renderObj=COA
renderObj.10=文本
renderObj.10.field=somefield
renderObj.10.wrap=|
}
#将myRecords添加到流体变量。我假设fluidtemplate位于第10页
page.10.variables.myRecords
在流体中:
<f:render.raw>{myRecords}</f:render.raw>
{myRecords}
正如您所看到的,TS解决方案几乎与流体无关,因为html是在TS中构建的。我建议使用自己的插件。将关系字段添加到页面模型并创建一个小插件并不需要太多时间,这是一个很好的进一步开发培训。最好的方法是扩展/创建页面模型并创建一个插件来显示您的内容 也可以用打字稿来完成
myRecords = CONTENT
myRecords {
table = tx_user_myext_mycustomrow
select {
pidInList = root,-1
selectFields = tx_user_myext_mycustomrow.*
join = tx_user_myext_mycustomrow_pages_MM ON tx_user_myext_mycustomrow_pages_MM.uid_local = tx_user_myext_mycustomrow.uid
where.data = field:_ORIG_uid // field:uid
where.intval = 1
where.wrap = tx_user_myext_mycustomrow_pages_MM.uid_foreign=|
orderBy = tx_user_myext_mycustomrow_pages_MM.sorting_foreign
}
renderObj = COA
renderObj.10 = TEXT
renderObj.10.field = somefield
renderObj.10.wrap = <h1>|</h1>
}
# add myRecords to your fluid variables. I assume that the fluidtemplate is in page.10
page.10.variables.myRecords < myRecords
myRecords=CONTENT
我的记录{
table=tx\u user\u myext\u mycustomrow
挑选{
pidInList=根,-1
选择fields=tx\u user\u myext\u mycustomrow*
join=tx\u user\u myext\u mycustomrow\u pages\u MM ON tx\u user\u myext\u mycustomrow\u pages\u MM.uid\u local=tx\u user\u myext\u mycustomrow.uid
其中.data=field:\u ORIG\u uid//field:uid
其中,intval=1
其中.wrap=tx\u user\u myext\u mycustomrow\u pages\u MM.uid\u foreign=|
orderBy=tx\u user\u myext\u mycustomrow\u pages\u MM.sorting\u foreign
}
renderObj=COA
renderObj.10=文本
renderObj.10.field=somefield
renderObj.10.wrap=|
}
#将myRecords添加到流体变量。我假设fluidtemplate位于第10页
page.10.variables.myRecords
在流体中:
<f:render.raw>{myRecords}</f:render.raw>
{myRecords}
正如您所看到的,TS解决方案几乎与流体无关,因为html是在TS中构建的。我建议使用自己的插件。将关系字段添加到页面模型并创建一个小插件并不需要太多时间,这是对进一步开发的一个很好的培训。您不能使用
数据库查询处理器来实现这一点吗
打字脚本配置示例:
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_address
pidInList = 123
where = company="Acme" AND first_name="Ralph"
order = RAND()
as = addresses
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
page.10.variables.myRecords = CONTENT
page.10.variables.myRecords {
table = tx_user_myext_mycustomrow
select {
pidInList = root,-1
selectFields = tx_user_myext_mycustomrow.*
join = tx_user_myext_mycustomrow_pages_MM ON tx_user_myext_mycustomrow_pages_MM.uid_local = tx_user_myext_mycustomrow.uid
where.data = field:uid
where.intval = 1
where.wrap = tx_user_myext_mycustomrow_pages_MM.uid_foreign=|
orderBy = tx_user_myext_mycustomrow_pages_MM.sorting_foreign
}
renderObj = FLUIDTEMPLATE
renderObj {
file = EXT:tx_user_myext/Resources/Private/Partials/MyTemplate.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10.references.fieldName = tx_user_myext_myfield
}
}
}
}
您不能使用数据库查询处理器
吗
打字脚本配置示例:
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_address
pidInList = 123
where = company="Acme" AND first_name="Ralph"
order = RAND()
as = addresses
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
page.10.variables.myRecords = CONTENT
page.10.variables.myRecords {
table = tx_user_myext_mycustomrow
select {
pidInList = root,-1
selectFields = tx_user_myext_mycustomrow.*
join = tx_user_myext_mycustomrow_pages_MM ON tx_user_myext_mycustomrow_pages_MM.uid_local = tx_user_myext_mycustomrow.uid
where.data = field:uid
where.intval = 1
where.wrap = tx_user_myext_mycustomrow_pages_MM.uid_foreign=|
orderBy = tx_user_myext_mycustomrow_pages_MM.sorting_foreign
}
renderObj = FLUIDTEMPLATE
renderObj {
file = EXT:tx_user_myext/Resources/Private/Partials/MyTemplate.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10.references.fieldName = tx_user_myext_myfield
}
}
}
}
使用DatabaseQueryProcessor(正如@bschauer所说的),可以使用一个partial将HTML与打字稿分开
打字稿配置:
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_address
pidInList = 123
where = company="Acme" AND first_name="Ralph"
order = RAND()
as = addresses
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
page.10.variables.myRecords = CONTENT
page.10.variables.myRecords {
table = tx_user_myext_mycustomrow
select {
pidInList = root,-1
selectFields = tx_user_myext_mycustomrow.*
join = tx_user_myext_mycustomrow_pages_MM ON tx_user_myext_mycustomrow_pages_MM.uid_local = tx_user_myext_mycustomrow.uid
where.data = field:uid
where.intval = 1
where.wrap = tx_user_myext_mycustomrow_pages_MM.uid_foreign=|
orderBy = tx_user_myext_mycustomrow_pages_MM.sorting_foreign
}
renderObj = FLUIDTEMPLATE
renderObj {
file = EXT:tx_user_myext/Resources/Private/Partials/MyTemplate.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10.references.fieldName = tx_user_myext_myfield
}
}
}
}
部分MyTemplate.html:
h1>{data.somefield}</h1>
h1>{data.somefield}
在流体模板中:
<f:format.raw>{myRecords}</f:format.raw>
{myRecords}
使用DatabaseQueryProcessor(正如@bschauer所说),可以使用一个partial将HTML与打字稿分开
打字稿配置:
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_address
pidInList = 123
where = company="Acme" AND first_name="Ralph"
order = RAND()
as = addresses
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
page.10.variables.myRecords = CONTENT
page.10.variables.myRecords {
table = tx_user_myext_mycustomrow
select {
pidInList = root,-1
selectFields = tx_user_myext_mycustomrow.*
join = tx_user_myext_mycustomrow_pages_MM ON tx_user_myext_mycustomrow_pages_MM.uid_local = tx_user_myext_mycustomrow.uid
where.data = field:uid
where.intval = 1
where.wrap = tx_user_myext_mycustomrow_pages_MM.uid_foreign=|
orderBy = tx_user_myext_mycustomrow_pages_MM.sorting_foreign
}
renderObj = FLUIDTEMPLATE
renderObj {
file = EXT:tx_user_myext/Resources/Private/Partials/MyTemplate.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10.references.fieldName = tx_user_myext_myfield
}
}
}
}
部分MyTemplate.html:
h1>{data.somefield}</h1>
h1>{data.somefield}
在流体模板中:
<f:format.raw>{myRecords}</f:format.raw>
{myRecords}
如何获取{data.myfield}
中的数据变量?它是否加载了一些扩展名,或者您使用的是纯打字脚本?@DimitriL。不,我知道,{data}
是流体模板的默认变量的一部分,包含当前页面记录的数据。我猜错了吗?据我所知,如果你没有在插件中使用流体模板,那么流体模板中就没有默认变量,但可能是我遗漏了一些更改。{data}怎么说?@DimitriL。谢谢你的回复。首先,调试{u all}
说,有两个变量可用于