DocHeaderComponent

Document header component for backend modules.

This component manages the header area of backend module views, providing:

  • Breadcrumb navigation (via BreadcrumbContext)
  • Button bar for action buttons (save, close, delete, etc.)
  • Drop-down menus for module-specific actions

The component can be enabled or disabled to control visibility of the entire document header. It integrates with the ModuleTemplate to provide a consistent header across all backend modules.

Usage in a controller:

public function __construct(
    protected readonly ComponentFactory $componentFactory,
) }

public function myAction(): ResponseInterface
{
    $view = $this->moduleTemplateFactory->create($request);
    $docHeader = $view->getDocHeaderComponent();

    // Set breadcrumb for a page
    $docHeader->setPageBreadcrumb($pageInfo);

    // Add action buttons using ComponentFactory
    $buttonBar = $docHeader->getButtonBar();
    $saveButton = $this->componentFactory->createSaveButton('editform');
    $buttonBar->addButton($saveButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
}
Attributes
#[Autoconfigure]
$public: true

Table of Contents

Properties

$breadcrumb  : Breadcrumb
Breadcrumb component for rendering navigation trails.
$breadcrumbContext  : BreadcrumbContext|null
Context information for breadcrumb rendering.
$breadcrumbFactory  : BreadcrumbFactory
$buttonBar  : ButtonBar
Button bar component for managing action buttons.
$enabled  : bool
Whether the document header is enabled and should be rendered.
$menuRegistry  : MenuRegistry
$metaInformation  : MetaInformation
Legacy meta information component (deprecated).
$recordFactory  : RecordFactory

Methods

__construct()  : mixed
addBreadcrumbSuffixNode()  : void
Adds a suffix node to the current breadcrumb context.
disable()  : void
Disables this component to prevent rendering.
docHeaderContent()  : array<string|int, mixed>
Returns the complete document header content as an array for rendering.
enable()  : void
Enables this component for rendering.
getButtonBar()  : ButtonBar
Returns the button bar for adding action buttons to the document header.
getMenuRegistry()  : MenuRegistry
Returns the menu registry for adding drop-down menus to the document header.
isEnabled()  : bool
Determines whether this component is enabled and should be rendered.
setBreadcrumbContext()  : void
Sets the breadcrumb context for rendering.
setMetaInformation()  : void
Set page information
setMetaInformationForResource()  : void
Set meta information for a file/folder resource.
setPageBreadcrumb()  : void
Sets breadcrumb from a page record array.
setRecordBreadcrumb()  : void
Sets breadcrumb for editing a record.
setResourceBreadcrumb()  : void
Sets breadcrumb for any resource (file or folder).

Properties

$breadcrumb

Breadcrumb component for rendering navigation trails.

protected Breadcrumb $breadcrumb

$breadcrumbContext

Context information for breadcrumb rendering.

protected BreadcrumbContext|null $breadcrumbContext = null

Contains the main context (page, record, or resource) and optional suffix nodes for additional navigation elements.

$buttonBar

Button bar component for managing action buttons.

protected ButtonBar $buttonBar

$enabled

Whether the document header is enabled and should be rendered.

protected bool $enabled = true

$metaInformation

Legacy meta information component (deprecated).

Deprecated

Will be removed in TYPO3 v15. Use breadcrumbContext instead.

protected MetaInformation $metaInformation

Methods

addBreadcrumbSuffixNode()

Adds a suffix node to the current breadcrumb context.

public addBreadcrumbSuffixNode(BreadcrumbNode $node) : void

Suffix nodes are appended after the main breadcrumb trail and are useful for:

  • Indicating "Create New" actions
  • Showing "Edit Multiple" states
  • Adding custom contextual information

Example:

$docHeader->setPageBreadcrumb($pageInfo);
$docHeader->addBreadcrumbSuffixNode(
    new BreadcrumbNode(
        identifier: 'new',
        label: 'Create New Content Element',
        icon: 'actions-add'
    )
);

Note: This creates or modifies the breadcrumb context. If you need to build a complete context, use BreadcrumbFactory instead.

Parameters
$node : BreadcrumbNode

The node to append

disable()

Disables this component to prevent rendering.

public disable() : void

docHeaderContent()

Returns the complete document header content as an array for rendering.

public docHeaderContent(ServerRequestInterface|null $request) : array<string|int, mixed>

This method aggregates all components (buttons, menus, breadcrumbs) into a structured array that can be consumed by the Fluid template rendering the backend module layout.

The returned array structure:

  • 'enabled': Whether the document header should be rendered
  • 'buttons': Array of button configurations from the button bar
  • 'menus': Array of menu configurations from the menu registry
  • 'breadcrumb': Breadcrumb trail data from the breadcrumb context
Parameters
$request : ServerRequestInterface|null
Return values
array<string|int, mixed>

enable()

Enables this component for rendering.

public enable() : void

getButtonBar()

Returns the button bar for adding action buttons to the document header.

public getButtonBar() : ButtonBar

The button bar supports multiple button positions (left, right) and groups to organize buttons logically.

Return values
ButtonBar

isEnabled()

Determines whether this component is enabled and should be rendered.

public isEnabled() : bool

When disabled, the entire document header (including breadcrumbs, buttons, and menus) will not be displayed in the backend module.

Return values
bool

setBreadcrumbContext()

Sets the breadcrumb context for rendering.

public setBreadcrumbContext(BreadcrumbContext|null $breadcrumbContext) : void

This is the main API for providing breadcrumb information.

For common scenarios, use the convenience methods instead:

  • setPageBreadcrumb() for page records
  • setRecordBreadcrumb() for any record
  • setResourceBreadcrumb() for files or folders
Parameters
$breadcrumbContext : BreadcrumbContext|null

The breadcrumb context

setMetaInformation()

Set page information

public setMetaInformation(array<string|int, mixed> $metaInformation) : void
Deprecated

since v14, will be removed in v15. Use setPageBreadcrumb() instead.

Parameters
$metaInformation : array<string|int, mixed>

Record array

setMetaInformationForResource()

Set meta information for a file/folder resource.

public setMetaInformationForResource(ResourceInterface $resource) : void
Deprecated

since v14, will be removed in v15. Use setResourceBreadcrumb() instead.

Parameters
$resource : ResourceInterface

setPageBreadcrumb()

Sets breadcrumb from a page record array.

public setPageBreadcrumb(array<string|int, mixed> $pageRecord) : void

This is the direct replacement for setMetaInformation().

Example: $view->getDocHeaderComponent()->setPageBreadcrumb($pageInfo);

Parameters
$pageRecord : array<string|int, mixed>

The page record array (must contain 'uid')

setRecordBreadcrumb()

Sets breadcrumb for editing a record.

public setRecordBreadcrumb(string $table, int $uid) : void

Example: $view->getDocHeaderComponent()->setRecordBreadcrumb('tt_content', 123);

Parameters
$table : string

The table name

$uid : int

The record UID

setResourceBreadcrumb()

Sets breadcrumb for any resource (file or folder).

public setResourceBreadcrumb(ResourceInterface $resource) : void

Example: $view->getDocHeaderComponent()->setResourceBreadcrumb($file); $view->getDocHeaderComponent()->setResourceBreadcrumb($folder);

Parameters
$resource : ResourceInterface

The resource (file or folder)


        
On this page

Search results