Extending the Admin Panel¶
Extension authors can write their own modules or add submodules to existing modules.
Creating additional modules¶
An admin panel module commonly has:
- An icon, an identifier, a short info and a label
- initializeModule and onSubmit methods for initialization (done early in the TYPO3 Request) and for reacting to changes (onSubmit is executed when the settings are updated)
- Settings that influence page rendering or page display
- Methods to provide custom CSS and JavaScript files
- Submodules
To create your own Admin Panel module¶
- Create a new PHP class extending
\TYPO3\
.CMS\ Adminpanel\ Modules\ Abstract Module -
Implement at least the following methods:
get
- A unique identifier for your module. For exampleIdentifier mynamespace_
modulename get
- An icon identifier which is resolved via the icon API. Make sure to use a registered icon here.Icon Identifier get
- Speaking label for the module. You can access language files viaLabel $this->get
Language Service () get
- Displayed next to the module label, may contain aggregated infos (such asShort Info Total Parse Time: 200ms
)
-
Register your module by adding the following in your
ext_
localconf. php $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['mynamespace_modulename'] = [ 'module' => \Your\Namespace\Adminpanel\Modules\YourModule::class, 'before' => ['cache'], ];
Copied!
Using before
or after
you can influence where your module will be
displayed in the module menu by referencing the identifier / array key of
other modules.
Modules themselves do provide settings for the page rendering and global actions (like preview settings, clearing caches or adding action buttons for editing the page) but do not provide further content.
If you want to display additional content in the Admin Panel (like rendering times or backtraces), you have to add a submodule to your main module.
To provide settings in a module, implement the method get
, which has
to return rendered HTML form elements (but without the form tag), ready to be
used in the Admin Panel main form.
Adding a sub-module¶
An Admin Panel submodule has:
- An identifier and a label.
- initializeModule and onSubmit methods for initialization (done early in the TYPO3 Request) and reacting to changes (onSubmit is executed when the settings are updated).
- Module content (for example the Info submodules display information about the current page or server configuration).
- Settings influencing their module content (for example the TypoScript Time / Rendering sub module has settings that influence whether to display messages or not).
As soon as a module has a submodule it will be displayed in the main Admin Panel. Modules without submodules may only provide settings, and are only displayed in the Settings overview.
Adding a submodule is similar to adding a module.
-
First, create a new class that extends
Abstract
. Implement at least the following methods:Sub Module get
- A unique identifier for your sub module (for exampleIdentifier submodulename
)get
- Speaking label for the module - you can access language files viaLabel $this->get
Language Service () get
- The rendered HTML content for your moduleContent
-
Register your sub module by adding the following in your
ext_
localconf. php $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['mynamespace_modulename']['submodules']['submodulename'] = [ 'module' => \Your\Namespace\Adminpanel\Modules\YourModule\Submodule::class ];
Copied!
Where mynamespace_
references the main module where you want to
add your submodule, and submodulename
is the identifier of your sub module.
This way, you can also register new custom sub modules to existing main
modules.
Examples¶
You can find examples for main and sub modules and their registration in the Admin Panel extension. Short ones for a quick look are:
adminpanel/
(Submodule)Classes/ Modules/ Info/ Php Information. php adminpanel/
(Main module, serves as submodule wrapper only)Classes/ Modules/ Info Module. php adminpanel/
(Main module, custom rendering settings)Classes/ Modules/ Cache Module. php