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

时间:2018-04-13 12:26:09

标签: typo3 typo3-9.x

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,
                ]
            ]
        ]
    ],

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

2 个答案:

答案 0 :(得分: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中。也许这个微小的区别使它更加清楚了。

图标

关于图标,与早期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版开始实施新的图标注册表

答案 1 :(得分:-2)

不要忘记 YourExtension/Configuration/Backend/AjaxRoutes.php 中的配置。请参阅documentation

相关问题