DocHeaderComponent
The
\TYPO3\ can be
used to display a standardized header section in a backend module with buttons,
menus etc. It can also be used to hide the header section in case it is
not desired to display it.
The module header displayed by the DocHeaderComponent
You can get the
Doc with
\TYPO3\CMS\Backend\Template\ModuleTemplate::getDocHeaderComponent
from your module template.
Table of contents
DocHeaderComponent API
It has the following methods:
Example: Build a module header with buttons and a menu
The following example is extracted from the example Extbase extension t3docs/blog-example . See the complete source code at t3doc/blog-example (GitHub).
We use the DocHeaderComponent to register buttons and a menu to the module header.
<?php
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
class BackendController extends ActionController
{
private function modifyDocHeaderComponent(ModuleTemplate $view, string &$context): void
{
$menu = $this->buildMenu($view, $context);
$view->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
$buttonBar = $view->getDocHeaderComponent()->getButtonBar();
$this->addButtons($buttonBar);
$metaInformation = $this->getMetaInformation();
if (is_array($metaInformation)) {
$view->getDocHeaderComponent()->setMetaInformation($metaInformation);
}
}
protected function initializeModuleTemplate(
ServerRequestInterface $request,
): ModuleTemplate {
$view = $this->moduleTemplateFactory->create($request);
$context = '';
$this->modifyDocHeaderComponent($view, $context);
$view->setFlashMessageQueue($this->getFlashMessageQueue());
$view->setTitle(
$this->getLanguageService()->sL('LLL:EXT:blog_example/Resources/Private/Language/Module/locallang_mod.xlf:mlang_tabs_tab'),
$context,
);
return $view;
}
}