1

如何在typo3 7 TCA 中添加自定义向导相关?TYPO3 9中的服装巫师如何实现?我已将我的条目添加到 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,
                ]
            ]
        ]
    ],

这不起作用。我想念什么?提前致谢。

4

2 回答 2

2

与您的向导类型相关,注册过程是不同的,并且在此处进行了广泛的解释。您可以保留 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 开始实施新的图标注册表

于 2018-08-29T08:12:32.110 回答
-2

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

于 2021-03-08T12:52:04.517 回答