How to add custom wizards in typo3 7 TCA?

2020-07-17 14:37发布

When I try to add the wizard named wizard_geo_selector in TCA ,there arised an error "module not registered".Please tell me how to register the wizard properly in the TCA.?

3条回答
倾城 Initia
2楼-- · 2020-07-17 14:53

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.

查看更多
你好瞎i
3楼-- · 2020-07-17 14:56

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

查看更多
一夜七次
4楼-- · 2020-07-17 14:56

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.

查看更多
登录 后发表回答