ModifyNewContentElementWizardItemsEvent¶
New in version 12.0
This event serves as a more powerful and flexible alternative
for the removed hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook']
.
The PSR-14 event
\TYPO3\CMS\Backend\Controller\Event\ModifyNewContentElementWizardItemsEvent
is called after TYPO3 has already prepared the wizard items,
defined in page TSconfig (mod.wizards.newContentElement.wizardItems).
The event allows listeners to modify any available wizard item as well as adding new ones. It is therefore possible for the listeners to, for example, change the configuration, the position or to remove existing items altogether.
Example¶
Registration of the event listener in the extension's Services.yaml
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/modify-wizard-items'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\ModifyNewContentElementWizardItemsEvent;
final class MyEventListener
{
public function __invoke(ModifyNewContentElementWizardItemsEvent $event): void
{
// Add a new wizard item after "textpic"
$event->setWizardItem(
'my_element',
[
'iconIdentifier' => 'icon-my-element',
'title' => 'My element',
'description' => 'My element description',
'tt_content_defValues' => [
'CType' => 'my_element',
],
],
['after' => 'common_textpic'],
);
}
}
API¶
- class \TYPO3\CMS\Backend\Controller\Event\ ModifyNewContentElementWizardItemsEvent¶
-
Listeners to this Event will be able to modify the wizard items of the new content element wizard component
- getWizardItems ( ) ¶
-
- returntype
-
array
- setWizardItems ( array $wizardItems) ¶
-
- param array $wizardItems
-
the wizardItems
- hasWizardItem ( string $identifier) ¶
-
- param string $identifier
-
the identifier
- returntype
-
bool
- getWizardItem ( string $identifier) ¶
-
- param string $identifier
-
the identifier
- returntype
-
array
- setWizardItem ( string $identifier, array $configuration, array $position = []) ¶
-
Add a new wizard item with configuration at a defined position.
Can also be used to relocate existing items and to modify their configuration.
- param string $identifier
-
the identifier
- param array $configuration
-
the configuration
- param array $position
-
the position, default: []
- removeWizardItem ( string $identifier) ¶
-
- param string $identifier
-
the identifier
- returntype
-
bool
- getPageInfo ( ) ¶
-
Provides information about the current page making use of the wizard.
- returntype
-
array
- getColPos ( ) ¶
-
Provides information about the column position of the button that triggered the wizard.
- returntype
-
int
- getSysLanguage ( ) ¶
-
Provides information about the language used while triggering the wizard.
- returntype
-
int
- getUidPid ( ) ¶
-
Provides information about the element to position the new element after (uid) or into (pid).
- returntype
-
int