首页 文章

如何在TYPO3 9 TCA中添加自定义向导?

提问于
浏览
1

How to add custom wizards in typo3 7 TCA?相关如何实施TYPO3 9中的costum向导?我已将我的条目添加到Routes.php中

return [
    'tx_csseo_preview' => [
        'path' => '/wizard/tx_csseo/preview',
        'target' => \Clickstorm\CsSeo\UserFunc\PreviewWizard::class . '::render'
    ],
    'tx_csseo_permalink' => [
        'path' => '/wizard/tx_csseo/permalink',
        'target' => \Clickstorm\CsSeo\UserFunc\PermalinkWizard::class . '::render'
    ]
];

如何将它们添加到我的TCA字段?

'tx_csseo_title' => [
        'label' => 'LLL:EXT:cs_seo/Resources/Private/Language/locallang_db.xlf:pages.tx_csseo_title',
        'exclude' => 1,
        'config' => [
            'type' => 'input',
            'max' => $extConf['maxTitle'],
            'eval' => 'trim',
            'fieldWizard' => [
                'tx_csseo_preview' => [
                    'disabled' => false,
                ]
            ]
        ]
    ],

这不起作用 . 我错过了什么?提前致谢 .

1 回答

  • 2

    与您的向导类型相关,注册过程是不同的,并且广泛解释here . 您可以将Routes.php中的条目留下(如果内部没有其他内容,甚至可能是整个文件) .

    注册在 ext_localconf.php 完成:

    $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1485351217] = [
       'nodeName' => 'importDataControl',
       'priority' => 30,
       'class' => \T3G\Something\FormEngine\FieldControl\ImportDataControl::class
    ];
    

    然后在TCA中引用新向导:

    'somefield' => [
       'label'   => $langFile . ':pages.somefield',
       'config'  => [
          'type' => 'input',
          'eval' => 'int, unique',
          'fieldControl' => [
             'importControl' => [
                'renderType' => 'importDataControl'
             ]
          ]
       ]
    ],
    

    然后终于上课了“神奇”

    declare(strict_types=1);
    
    namespace T3G\Something\FormEngine\FieldControl;
    
    use TYPO3\CMS\Backend\Form\AbstractNode;
    
    class ImportDataControl extends AbstractNode
    {
       public function render()
       {
          $result = [
             'iconIdentifier' => 'import-data',
             'title' => $GLOBALS['LANG']->sL('LLL:EXT:something/Resources/Private/Language/locallang_db.xlf:pages.importData'),
             'linkAttributes' => [
                'class' => 'importData ',
                'data-id' => $this->data['databaseRow']['somefield']
             ],
             'requireJsModules' => ['TYPO3/CMS/Something/ImportData'],
          ];
          return $result;
       }
    }
    

    在链接的示例中,仍然存在具有相应文件的Ajax路由,包括特殊定义的路由,但是不需要显示基本向导 .

    关于 ext_localconf.php 中的注册,数字 1485351217 上方显示为数组键 . 对于自己的注册节点,只需将当前时间计算为unix-timestamp,然后输入 . 因此,它与任何已注册节点的其他定义都会被误认 .

    与链接的示例相比,我使用了稍微不同的描述,因此我在ext_localconf.php registering 中调用该进程,并将其包含在TCA referencing 中 . 也许这个微小的差异使它更加清晰 .

    Icons

    关于图标,早期的TYPO3版本仍然存在差异,它们现在也必须注册,而在TCA中它们也仅通过注册名称引用 . 这里的TCA文件没有引用图标,但下面的类使用了它 . 以下是如何在ext_tables.php中注册图标的示例:

    $systemIconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
    $systemIconRegistry->registerIcon(
        'imagemapwizard_link_edit',
        \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
        [
            'source' => 'EXT:imagemap_wizard/Resources/Public/Icons/link_edit.png'
        ]
    );
    

    从TYPO3版本7.5开始实施新的图标注册表

相关问题