1

画像アップロード拡張機能を変更していて、画像をカテゴリに配置できる機能に取り組んでいます。

現在、カテゴリは、foreign_table を使用してテーブル (tx_gallery_categories と呼ばれる) からカテゴリを取得する選択フィールドにリストされ、保存されると、カテゴリ ID (オプション フィールドの値) が tx_gallery_items と呼ばれるテーブルに保存されます。

しかし、その列はもう必要ありません (最初は間違っていました)。選択したカテゴリに応じて、TCA で tx_gallery_itemsCategory というテーブルを更新し、itemId が保存された画像の uid と等しい categoryId を設定します。

これがTCAです(categoryId以外のすべての列を削除しました)。categoryIdは、これから移動したいものであり、tx_gallery_itemsCategoryに接続されている独自のTCAに移動したいと思います。

$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")
)

);

しかし、そのように機能する代わりに、tx_gallery_items から tx_gallery_items と tx_gallery_categories の間の多対多のテーブルである tx_gallery_itemsCategory という別のテーブルに画像 uid を保存したい

ここにテーブルがあります:

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 での私の最初の試みであり、これらすべてがどのように接続されているかについて非常に混乱しています。誰かが私よりもこれをよく知っていることを願っています:)ありがとう。

4

1 に答える 1

2

tcemainコンポーネントに実装されているフックの概念があります。processDatamap_postProcessFieldArrayレコードがバックエンドに保存されたときに呼び出されるというものがあります。したがって、それが「自分のもの」であるかどうかを確認し、他のクエリや変更したいことを実行できます。

この機能の使用方法の例があります。それはかなり古いですが、それでもそのように機能しているはずです。

于 2012-06-29T07:17:11.340 に答える