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\
and implementingCMS\ Adminpanel\ Module Api\ Abstract Module TYPO3\
. If you don't implement theCMS\ Adminpanel\ Module Api\ Short Info Provider Interface Short
, your module will not be shown in the module menu.Info Provider Interface -
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_
. Usinglocalconf. php before
orafter
you can influence where your module will be
displayed in the module menu by referencing the identifier / array key of other modules.
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['mynamespace_modulename'] = [ 'module' => \Your\Namespace\Adminpanel\Modules\YourModule::class, 'before' => ['cache'], ];
Copied!
- Ensure that your module class is defined as 'public' in the
Services.
file.yaml
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.
Adding settings¶
Page settings¶
Page settings, like "Preview" or "Cache", are accessible via the "Settings" section in the module menu.
To provide custom page settings, your main module needs to implement the \TYPO3\
interface.
The corresponding method get
returns rendered HTML form elements (but without the form tag).
Examples¶
\TYPO3\
CMS\ Adminpanel\ Modules\ Cache Module \TYPO3\
CMS\ Adminpanel\ Modules\ Preview Module
Module settings¶
Module settings are accessible via the cogwheel-button in the opened module.
To provide settings, your submodule needs to implement the \TYPO3\
interface.
The respective method get
returns rendered HTML form elements (but without the form tag).
Examples¶
\TYPO3\
CMS\ Adminpanel\ Modules\ Debug\ Log \TYPO3\
CMS\ Adminpanel\ Modules\ Ts Debug\ Typo Script Waterfall
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