简体   繁体   English

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

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

Related to How to add custom wizards in typo3 7 TCA?如何在typo3 7 TCA 中添加自定义向导相关 how can costum wizards in TYPO3 9 be implemented?如何实现 TYPO3 9 中的服装向导? I've added my entry to the Routes.php我已将我的条目添加到 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'
    ]
];

How can I add them now to my TCA field?我现在如何将它们添加到我的 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,
                ]
            ]
        ]
    ],

This does not work.这不起作用。 What do I miss?我想念什么? Thanks in advance.提前致谢。

Related to your kind of wizard the registration-process is different and extensive explained here .与您的向导类型相关的注册过程是不同的,并且在此处进行了广泛的解释。 You can leave the entries in Routes.php away (perhaps even the whole file if nothing else is inside).您可以保留 Routes.php 中的条目(如果里面没有其他内容,甚至可能是整个文件)。

Registration is done in ext_localconf.php :注册在ext_localconf.php完成:

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

Then reference the new wizard in TCA:然后在 TCA 中引用新向导:

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

Then finally the class with the "magic"然后终于有了“魔法”的班级

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;
   }
}

In the linked example there is still an Ajax Route with corresponding files, including a special defined route, but that's not required to get the basic wizard shown.在链接的示例中,仍然有一个带有相应文件的 Ajax 路由,包括一个特殊定义的路由,但这不是显示基本向导所必需的。

Concerning the registration in ext_localconf.php there is above the number 1485351217 as array-key shown.关于ext_localconf.php的注册,数字1485351217上方1485351217为数组键。 For an own registered node just calculate once the current time as unix-timestamp and enter that instead.对于自己注册的节点,只需将当前时间计算为 unix-timestamp 并输入。 So it's unique and can't be mistaken with other definitions of any registered nodes.所以它是独一无二的,不会与任何注册节点的其他定义混淆。

In contrast to the linked example I used slightly different descriptions, so I call the process in ext_localconf.php registering , and the inclusion in TCA referencing .与链接示例相比,我使用了稍微不同的描述,因此我在 ext_localconf.php 中调用该过程registering ,并将包含在 TCA referencing Perhaps this small difference makes it a bit more clear.也许这个微小的差异让它更清楚一点。

Icons图标

Concerning Icons there is still a difference to earlier TYPO3 versions, they have to be registered now too and in TCA they are only referenced too by the registered name.关于图标,与早期的 TYPO3 版本仍有区别,它们现在也必须注册,并且在 TCA 中也仅通过注册名称引用它们。 Here in the TCA-file is no icon referenced but the class below makes usage of it.在 TCA 文件中没有引用图标,但下面的类使用了它。 Here is an example how an icon has to be registered in ext_tables.php:这是一个如何在 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'
    ]
);

The new icon registry is implemented starting with TYPO3 version 7.5新的图标注册表从 TYPO3 7.5 版开始实施

Don't forget the configuration in YourExtension/Configuration/Backend/AjaxRoutes.php .不要忘记YourExtension/Configuration/Backend/AjaxRoutes.php 中的配置 See the documentation查看文档

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

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