1

バックエンドで TCA フォームを作成しました。選択フィールド「タイプ」の値に応じて何が変わりますか:

この選択フィールドには、基本的に次のオプションが含まれています。

  • rte テキスト
  • URL
  • 写真

「rte text」を選択すると「rte text」に指定されたフィールドが表示され、url を選択すると「url」に指定されたフィールドが表示されるようにシステムを動作させることができます。

私の場合、コンテンツは常にデータベースの「コンテンツ」フィールドに保存され、選択したタイプは「タイプ」フィールドに保存されます。

私の問題は、選択したタイプに応じて、「コンテンツ」フォームフィールド/構成を変更する方法が見つからないことです。

たとえば、「rte text」を選択すると、コンテンツ フィールドに次のような構成 (リッチ テキスト エディター) を使用する必要があります。

'content' => array (        
        'exclude' => 0,     
        'label' => 'Content',       
        'config' => array (
            'type' => 'text',
            'cols' => '30',
            'rows' => '5',
            'wizards' => array(
                '_PADDING' => 2,
                'RTE' => array(
                    'notNewRecords' => 1,
                    'RTEonly'       => 1,
                    'type'          => 'script',
                    'title'         => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
                    'icon'          => 'wizard_rte2.gif',
                    'script'        => 'wizard_rte.php',
                ),
            ),
        )
    ),

「画像」を選択すると、コンテンツフィールドにこの種の構成(ファイルアップローダー)を使用する必要があります。

'content' => array (        
        'exclude' => 0,     
        'label' => 'Content',       
        'config' => array (
            'type' => 'group',
            'internal_type' => 'file',
            'allowed' => '',    
            'disallowed' => 'php,php3', 
            'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], 
            'uploadfolder' => 'uploads/tx_uploadshere',
            'size' => 1,    
            'minitems' => 0,
            'maxitems' => 1,
        )
    ),

選択ボックスの値に応じてその構成を変更する方法はありますか? 配列に 2 つのコンテンツを入れようとしましたが、うまくいきませんでした。

4

1 に答える 1

3

残念ながら、 を介して単一のフィールドのプロパティを変更することはできませんtype

ただし、表示される内容に影響を与えることはできます。したがって、2 つの独立したフィールドを構成して、表示を切り替えることができます。

ext_tables.php :

$TCA['tx_yourextension_yourtable'] = array(
    'ctrl' => array(
        //...
        'type'=>'type',
        //...
    ),
);

TCA.php :

$TCA['tx_yourextension_yourtable'] = array(
    'ctrl' => $TCA['tx_yourextension_yourtable']['ctrl'],
    'types' => array(
        0 => array('showitem' => 'content_rte'),
        1 => array('showitem' => 'content_image'),
    ),
    'columns' => array(
        'content_rte' => array(
            'exclude' => 0,
            'label' => 'Content',
            'config' => array(
                'type' => 'text',
                'cols' => '30',
                'rows' => '5',
                'wizards' => array(
                    '_PADDING' => 2,
                    'RTE' => array(
                        'notNewRecords' => 1,
                        'RTEonly' => 1,
                        'type' => 'script',
                        'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
                        'icon' => 'wizard_rte2.gif',
                        'script' => 'wizard_rte.php',
                    ),
                ),
            )
        ),
        'content_upload' => array(
            'exclude' => 0,
            'label' => 'Content',
            'config' => array(
                'type' => 'group',
                'internal_type' => 'file',
                'allowed' => '',
                'disallowed' => 'php,php3',
                'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
                'uploadfolder' => 'uploads/tx_uploadshere',
                'size' => 1,
                'minitems' => 0,
                'maxitems' => 1,
            )
        ),
    ),
    // ...
);

(注:簡単にするためhiddenに、などのシステムフィールドを削除しました)sys_language_uid

于 2012-03-19T21:43:37.310 に答える