Typo3 从一个带有外部_表的表中获取数据,并在TCA中更新到另一个表
我正在修改一个图像上传扩展,我正在开发一个可以将图像分类的功能 现在,类别列在一个选择字段中,该字段使用外来表格从表格(称为tx_gallery_categories)中获取类别,保存时,类别Id(选项字段中的值)将保存到称为tx_gallery_items的表格中 但是这个专栏不再需要了(我第一次错了)。根据您选择的类别,我希望TCA更新名为tx_gallery_itemsCategory的表,并设置categoryId,其中itemId等于保存的图像uid 这是TCA(我已经删除了categoryId旁边的所有其他列),categoryId是我想从中移出的,并且是它自己的TCA,它连接到tx_gallery_itemsCategory:Typo3 从一个带有外部_表的表中获取数据,并在TCA中更新到另一个表,typo3,Typo3,我正在修改一个图像上传扩展,我正在开发一个可以将图像分类的功能 现在,类别列在一个选择字段中,该字段使用外来表格从表格(称为tx_gallery_categories)中获取类别,保存时,类别Id(选项字段中的值)将保存到称为tx_gallery_items的表格中 但是这个专栏不再需要了(我第一次错了)。根据您选择的类别,我希望TCA更新名为tx_gallery_itemsCategory的表,并设置categoryId,其中itemId等于保存的图像uid 这是TCA(我已经删除了categ
$TCA["tx_gallery_items"] = array (
"ctrl" => $TCA["tx_gallery_items"]["ctrl"],
"interface" => array (
"showRecordFieldList" => "hidden,oid,filename, videoembedcode,caption"
),
"feInterface" => $TCA["tx_gallery_items"]["feInterface"],
"columns" => array (
"categoryId" => Array (
"exclude" => 1,
"label" => "LLL:EXT:gc_gallery/locallang_db.xml:tx_gallery_items.categories",
"config" => Array (
"type" => "select",
"foreign_table" => "tx_gallery_categories",
// "foreign_table_where" => " true"
// "itemsProcFunc" => "tx_gallery_getImageCategories->getCategories"
// 'default' => '123'
)
),
),
"types" => array (
"0" => array("showitem" => "hidden, oid, filename, categoryId, videoembedcode, caption, linkpid")
)
);
$TCA["tx_gallery_categories"] = array (
"ctrl" => $TCA["tx_gallery_categories"]["ctrl"],
"interface" => array (
"showRecordFieldList" => "categoryTitle"
),
"feInterface" => $TCA["tx_gallery_categories"]["feInterface"],
"columns" => array (
"categoryTitle" => Array (
"exclude" => 0,
"label" => "LLL:EXT:gc_gallery/locallang_db.xml:tx_gallery_items.categories",
"config" => Array (
"type" => "text",
"cols" => "30",
"rows" => "5",
)
)
),
"types" => array (
"0" => array("showitem" => "categoryTitle")
)
))
但我不想这样工作,而是想将图片uid从tx_gallery_项目保存到另一个名为tx_gallery_项目的表中,该表是tx_gallery_项目和tx_gallery_类别之间的多对多表
以下是表格:
tx_gallery_items:
uid | pid | ... (and many more but only uid is relevant)
432 | 34 | ...
tx_gallery_itemsCategory:
id | itemId | categoryId
1 | 432 | 1
tx_gallery_categories:
uid | pid | categoryTitle
1 | 34 | example category
下面是ext_tables.php
$TCA["tx_gallery_items"] = array (
"ctrl" => array (
'title' => 'LLL:EXT:gc_gallery/locallang_db.xml:tx_gallery_items',
'label' => 'filename',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => array (
'disabled' => 'hidden',
),
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'icon_tx_gallery_items.gif',
),
"feInterface" => array (
"fe_admin_fieldList" => "hidden, oid, filename, category, videoembedcode, caption, linkpid, categoryId",
)
);
$TCA["tx_gallery_categories"] = array (
"ctrl" => array (
'title' => 'LLL:EXT:gc_gallery/locallang_db.xml:tx_gallery_items',
'label' => 'categoryTitle',
'tstamp' => 'tstamp',
'sortby' => 'sorting',
'delete' => 'deleted',
// 'enablecolumns' => array (
// 'disabled' => 'hidden',
// ),
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'icon_tx_gallery_items.gif',
),
// "feInterface" => array (
// "fe_admin_fieldList" => "uid, pid, categoryTitle, categoryDescription, tstamp, sorting, deleted, hidden, categorySlug",
// )
);
所以我的问题是(我想)如何从用户正在编辑的当前图像中获取uid并将其保存到另一个表中
这是我第一次尝试使用TCA,我很困惑这一切是如何联系在一起的。
我希望每个人都比我更了解这一点:)
谢谢。tcemain组件中实现了钩子概念。有一个名为
processDatamap\u postProcessFieldArray
的程序,在后端保存任何记录时调用该程序。因此,您可以检查它是否是“您的”,并执行其他查询或任何您想要更改的操作
关于如何使用此功能,有很多问题。虽然它已经很老了,但它应该仍然是这样工作的