繁体   English   中英

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

[英]How to add custom wizards in TYPO3 9 TCA?

如何在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,
                ]
            ]
        ]
    ],

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

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

不要忘记YourExtension/Configuration/Backend/AjaxRoutes.php 中的配置 查看文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM