简体   繁体   English

如何在typo3 7 TCA中添加自定义向导?

[英]How to add custom wizards in typo3 7 TCA?

当我尝试在TCA中添加名为wizard_geo_selector的向导时,出现错误“模块未注册”。请告诉我如何在TCA中正确注册向导。

In TYPO3 Version 7.6 new wizards are added like this: 在TYPO3版本7.6中添加了新的向导,如下所示:

  1. Inside your extension create the directory Configuration/Backend/ 在您的扩展内部创建目录Configuration/Backend/
  2. In the new directory create a file Routes.php , it will be found automatically, no mentioning in ext_localconf.php or ext_tables.php is required. 在新目录中创建一个文件Routes.php ,它将自动找到, in ext_localconf.phpext_tables.php中不需要提及。 If you still need Ajax you can add the file AjaxRoutes.php in the same folder. 如果您仍然需要Ajax,可以将文件AjaxRoutes.php添加到同一文件夹中。
  3. Content for Routes.php : Routes.php内容:

     return array( 'my_wizard_element' => array( 'path' => '/wizard/tx_geoselecotor/geo_selector_wizard', 'target' => \\Path\\To\\your\\class\\WizardGeoSelector::class . '::WizardAction' ), ); 

Content for AjaxRoutes.php AjaxRoutes.php内容

<?php

 /**
  * Definitions for routes provided by EXT:backend
  * Contains all AJAX-based routes for entry points
  *
  * Currently the "access" property is only used so no token creation + validation is made
  * but will be extended further.
  */ 
 return array('my_ajax_element' => array(
         'path' => 'tx_geoselecotor/my_ajax_route',
         'target' => \Path\To\your\class\MyAjaxController::class .'::myAjaxFunction'
 ));

If you're unsure about the notation you can compare with existing entries in the Global Variables in the Backend: 如果您不确定符号,可以与后端的全局变量中的现有条目进行比较:

Navigate to System -> Configuration -> Backend Routes 导航到系统 - >配置 - >后端路由

The route of the paths is handled different, for Ajax it's always "ajax" prepended, so you've never to add it to the path, else it's twice in the route. 路径的路径处理不同,对于Ajax,它始终是“ajax”,所以你永远不会将它添加到路径中,否则它在路径中是两次。 For the common route there is no change concerning the defined string. 对于公共路由,定义的字符串没有变化。

  1. Now the wizard can be used and even it never has to be defined in ext_tables.php it has to be mentioned there from any table-field in the configuration-area (module[name]): 现在可以使用向导,甚至永远不必在ext_tables.php中定义它必须在配置区域(模块[名称])中的任何表字段中提及它:

     'table_field_for_wizard' => array( 'label' => 'LLL:EXT:my_extension/Resources/Private/Language/locallang.xml:table_name.tx_myextension_wizard', 'config' => array ( 'type' => 'user', 'userFunc' => 'Path/to/class/without/wizard->renderForm', 'wizards' => array( 'my_wizard' => array( 'type' => 'popup', 'title' => 'MyTitle', 'JSopenParams' => 'height=700,width=780,status=0,menubar=0,scrollbars=1', 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/img/link_popup.gif', 'module' => array( 'name' => 'my_wizard_element', 'urlParameters' => array( 'mode' => 'wizard', 'ajax' => '0', 'any' => '... parameters you need' ), ), ), '_VALIGN' => 'middle', '_PADDING' => '4', ), # Optional #'softref'=>'something', ), ), 

In the userFunc Path/to/class/without/wizard->renderForm you've to create a button which is linking to the wizard and onClick the wizard will open with the route you defined in Routes.php and the optional urlParameters. 在userFunc Path/to/class/without/wizard->renderForm您需要创建一个链接到向导的按钮,然后单击向导将打开您在Routes.php和可选urlParameters中定义的路径。

Currently I never found this whole item explained in the core-documentation. 目前我从来没有在核心文档中找到这整个项目。

Edit: 编辑:
Details about routing can be found here: Routing 有关路由的详细信息,请参阅: 路由

The rendering process can be found here: Rendering / NodeFactory You should probably read also the outer context of the linked paragraph. 可以在此处找到呈现过程: Rendering / NodeFactory您可能还应该阅读链接段落的外部上下文。

Edit 2: 编辑2:
An example extension can be found here, some things never work 100% but the wizard is working. 这里可以找到一个示例扩展,有些东西永远不会100%工作,但向导正在工作。 The extension is for TYPO3 Version 7: 扩展名适用于TYPO3版本7:
https://github.com/DavidBruchmann/imagemap_wizard https://github.com/DavidBruchmann/imagemap_wizard

IN TCA add the wizard like follows: 在TCA中添加如下向导:

'module' => array(
'name' => 'wizard_geo_selector',
),

In ext_tables.php register the wizard. 在ext_tables.php中注册向导。

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
        'wizard_geo_selector',
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/Yourwizardname/'
 );

Keep in mind this is deprecated since Typo3 7 and removed in Typo3 8.So you can use this method upto Typo3 7.For Typo3 8 do use the method specified by David below. 请记住,自Typo3 7以来已被弃用并在Typo3中删除8.因此,您可以使用此方法至Typo3 7.对于Typo3 8,请使用下面David指定的方法。

Ricky's answer doesn't really work anymore, since addModulePath ist deprecated since version 7. Ricky的答案不再适用,因为自版本7以来不推荐使用addModulePath。

Also, just registering the module like this still give's you said error. 此外,只是注册这样的模块仍然给你说错误。

The only thing that keeps the wizard going again is this: 让巫师再次进行的唯一事情就是这样:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule('wizard','pbsurvey_answers',"",\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY).'wizard/');

But when you add this, the module appears as a new point in your TYPO3 backend. 但是当你添加它时,模块在TYPO3后端显示为一个新点。

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

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