Skip to main content

Adding Information to the System Environment Toolbar

In TYPO3 CMS nearly every part is extendable, that’s one of my favorite things about it. While TYPO3 CMS core offers all of the essentials you need for content management, by adding extensions you can customize the CMS to your niche requirements. There are hundreds of solutions shared in the TER (TYPO3 Extension Repository) that’s a great place to start. Can’t find what you need? Time to build your own. When you have the right PHP skills to create extensions, you can create anything you want.

In this video, I’ll show you how you can extend the system information toolbar with custom information. The system information toolbar shows you details such as the version of TYPO3 that installation is running. What if you wanted to also add more details to help others, such as the current Git version being used?

To get the most out of this tutorial, you would need to know the basics of building TYPO3 extensions to follow along. This tutorial explains how to use the system information toolbar API.

All of the code used in the video is available on GitHub:  https://github.com/psychomieze/typo3-examples/tree/master/SystemStatus

Overview of extending system information in the toolbar.

To extend the system information toolbar, add the registration of the environment information to the ext_localconf of your extension:

Code ext_localconf.php:

if (!defined('TYPO3_MODE')) {
  die('Access denied.');
}

call_user_func(function () {
  if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) {
    \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)
      ->connect(
        \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class,
        'getSystemInformation',
        \T3G\Site\Backend\ToolbarItem\SystemInformationToolbarItemExtension::class,
        'addEnvironmentInformation'
      );
  }
});

Next, add a corresponding class implementing the method you defined in the localconf. The method should return an array with the title, value and icon you want to show:

use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem as CoreSystemInformationToolbarItem;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class SystemInformationToolbarItemExtension
{
  public function addEnvironmentInformation(CoreSystemInformationToolbarItem $systemInformation)
  {
    $systemInformation->addSystemInformation(
      'Site Version',
      htmlspecialchars(trim(CommandUtility::exec('git describe'))),
      GeneralUtility::makeInstance(IconFactory::class)
        ->getIcon('sysinfo-git', Icon::SIZE_SMALL)->render(),
    );
  }
}

For more information on how to use the icon factory take a look at the Icon API documentation.

You'll find answers to other frequently asked technical questions, instructional clips and all sorts of helpful videos on our TYPO3 YouTube channel. Come along and join us there. If you find this useful, please share the link on your network.

Comments

Hey Susi,

I used your example for an extension and was stuck with the icon. I found out that you don't need to put the rendered icon as third parameter, only the icon identifier as string.

Greets and stay healthy

Thomas

Hi Susi,

nice and short article. Thank you.

Some improvements:

* Remove the comma after 'render()' in the class.

* Add the missing use statements for the Icon classes.

* Add the information for which TYPO3 versions the code is valid.

I'd like if the other ToolbarItems would be extendable like this, too.

Claudia

Write comment

* These fields are required