2012-03-19 42 views
1

我在后台一个TCA形式提出,究竟会因所选择领域的“类型”的值更改:TYPO3的,TCA形式查看取决于所选择的选项

该选择字段包含基本选项:

  • RTE文本
  • 网址
  • 图片

我可以使系统工作,所以,该当选择“rte text”时,它会显示“rte text”的指定字段,当选择url时会显示“url”的指定字段等。

在我的情况下,内容总是保存在数据库的“内容“,所选类型保存在”类型“字段中。

我的问题是,我还没有找到一种方法来改变“内容”窗体域/配置,具体取决于所选的类型。

例如,当我选择“RTE文本”应该用于内容领域的这种配置的(富文本编辑器):

'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, 
     ) 
    ), 

有没有办法根据选择框中的值更改该配置。我试图把两个内容放在一个数组中,但没有按照这种方式工作。

+0

它是possi可以用额外的PHP实现你想要的,但我认为在一个表字段中混合不同的内容是不正确的。我认为@konsolenfreddy提出的方法会更好。 – tmt 2012-03-20 07:54:46

回答

3

不幸的是,您无法通过type更改单个字段的属性。

但是,您可以影响正在显示的内容。所以,你可以配置两个独立的领域和切换显示:

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等,为了简单起见)