How to add custom wizards in typo3 7 TCA?

拜拜、爱过 提交于 2019-12-04 09:05:52

In TYPO3 Version 7.6 new wizards are added like this:

  1. Inside your extension create the directory 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. If you still need Ajax you can add the file AjaxRoutes.php in the same folder.
  3. Content for 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

<?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. 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]):

    '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.

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.

Edit 2:
An example extension can be found here, some things never work 100% but the wizard is working. The extension is for TYPO3 Version 7:
https://github.com/DavidBruchmann/imagemap_wizard

IN TCA add the wizard like follows:

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

In ext_tables.php register the wizard.

\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.

Ricky's answer doesn't really work anymore, since addModulePath ist deprecated since version 7.

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!