Php TYPO3无法在自定义内容元素的模板中使用dataProcessing获取数据
我创建了一个带有自定义字段的自定义内容元素。 我在tt_content.php的覆盖中添加了这样的自定义字段Php TYPO3无法在自定义内容元素的模板中使用dataProcessing获取数据,php,typo3,typoscript,Php,Typo3,Typoscript,我创建了一个带有自定义字段的自定义内容元素。 我在tt_content.php的覆盖中添加了这样的自定义字段 $elements = [ 'myCustomField' => [ 'exclude' => true, 'label' => 'The label of my field', 'config' => [ 'type' => 'select', 'ren
$elements = [
'myCustomField' => [
'exclude' => true,
'label' => 'The label of my field',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_vendor_domain_model_myfavoritepictures,
],
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $elements);
此字段包含在“我的自定义内容”元素的TCA中,它存储与包含图片的选定记录的关系。
自定义内容元素的fluidtemplate仅包含调试viewhelper
我试图实现的是获取记录的图片,这些图片是在myCustomField
中选择的。为此,我尝试使用官方TYPO3文档中描述的“DatabaseQueryProcessor”:
ce\u mycustomcontentelement
但是,对于dataProcessing属性中定义的字段“myFavoritePictures”,我从自定义内容元素的fluidtemplate中的debug viewhelper获得一个空数组。我猜,我没有正确地配置数据处理程序,但不幸的是,我不知道我可能出了什么问题。也许,您正在与缺少的
pidInList
作斗争。如果未配置pidInList
,则当前页面将用于选择记录。如果您的tx\u供应商\u域\u型号\u myfavoritepictures
记录未保存在同一页上,则找不到任何内容。如果您的tx\u供应商\u域\u模型\u myfavoritepictures
记录存储在sysfolder中,请将其PID配置为pidInList
。谢谢,在配置pidInList
后,问题得到了解决
ce_mycustomcontentelement < lib.customContentElement
ce_mycustomcontentelement {
templateName = CeMyCustomContentElement
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
dataProcessing.10 {
if.isTrue.field = myCustomField
table = tx_vendor_domain_model_myfavoritepictures
as = myFavoritePictures
// recursively process the files in the records with the FilesProcessor
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = picture
}
}
}
}