typo3 - Get data from one table with foreign_table and update to another in TCA -
i'm modifying image upload extension , i'm working on feature images can placed in categories.
right categories listed in select field uses foreign_table categories table (called tx_gallery_categories) , when saved category id (the value in option field) saved table called tx_gallery_items.
but column no longer needed (i wrong first time). depending on category choose want tca update table called tx_gallery_itemscategory , set categoryid itemid equal saved images uid
here tca (i have removed other columns beside categoryid) , categoryid 1 want move out this, think, , in it's own tca connected tx_gallery_itemscategory:
$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") ) );
but instead of working want save images uid tx_gallery_items table called tx_gallery_itemscategory many many table between tx_gallery_items , tx_gallery_categories
here tables:
tx_gallery_items: uid | pid | ... (and many more uid relevant) 432 | 34 | ... tx_gallery_itemscategory: id | itemid | categoryid 1 | 432 | 1 tx_gallery_categories: uid | pid | categorytitle 1 | 34 | example category and here 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", // ) ); so question (i think) how can uid current image user editing , save table.
this first try tca , i'm confused on how connected. hope knows better me :) thanks.
there hook concept implemented in tcemain component. there 1 called processdatamap_postprocessfieldarray invoked when record saved in backend. thus, can check whether it's "yours" , other queries or whatever want change.
there an example of how use feature. although pretty old, should still working way.
Comments
Post a Comment