ModifyNewContentElementWizardItemsEvent
New in version 12.0
This event serves as a more powerful and flexible alternative
for the removed hook $GLOBALS
.
The PSR-14 event
\TYPO3\
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
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Controller\Event\ModifyNewContentElementWizardItemsEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
#[AsEventListener(
identifier: 'my-extension/backend/modify-wizard-items',
)]
final readonly 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'],
);
}
}
New in version 13.0
The PHP attribute \TYPO3\
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.
API
- class ModifyNewContentElementWizardItemsEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Controller\ Event\ Modify New Content Element Wizard Items Event
Listeners to this Event will be able to modify the wizard items of the new content element wizard component
- 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 $identifier
-
the identifier
- param $configuration
-
the configuration
- param $position
-
the position, default: []
- getColPos ( )
-
Provides information about the column position of the button that triggered the wizard.
- Returns
-
?int