ShortcutButton implements ButtonInterface, PositionInterface
Shortcut button for the DocHeader that enables bookmarking of backend module states.
This button allows users to create shortcuts (bookmarks) to specific module views with their context (e.g., specific page, record, or configuration). The shortcut preserves the route and arguments for quick access later.
The button is automatically added to all backend modules by default when shortcut context is provided. It's positioned on the right side of the button bar as the last button (group 91).
Example - Using automatic shortcut button (recommended):
public function myAction(ServerRequestInterface $request): ResponseInterface
{
$view = $this->moduleTemplateFactory->create($request);
// Set shortcut context - button is added automatically
$view->getDocHeaderComponent()->setShortcutContext(
routeIdentifier: 'my_module',
displayName: 'My Module: ' . $pageTitle,
arguments: ['id' => $pageId]
);
return $view->renderResponse('MyTemplate');
}
Note: As of TYPO3 v14, manually adding ShortcutButton is deprecated. Use DocHeaderComponent::setShortcutContext() instead.
Table of Contents
Interfaces
- ButtonInterface
- Interface for buttons in the document header.
- PositionInterface
- Interface for buttons that define their own fixed position and group.
Properties
- $arguments : array<string|int, mixed>
- $copyUrlToClipboard : bool
- $disabled : bool
- $displayName : string
- $routeIdentifier : string
Methods
- __toString() : string
- getDisplayName() : string
- getGroup() : int
- Returns the group number for this button.
- getPosition() : string
- Returns the position where this button should be rendered.
- getRouteIdentifier() : string
- getType() : string
- Returns the fully qualified class name as the component type identifier.
- isDisabled() : bool
- isValid() : bool
- Validates whether the component is properly configured and can be rendered.
- render() : string
- Renders the component as an HTML string.
- setArguments() : static
- setCopyUrlToClipboard() : static
- Defines whether the shortcut button should be extended to also allow copying the current URL to the operating systems' clipboard.
- setDisabled() : static
- setDisplayName() : static
- setRouteIdentifier() : static
- getBackendUser() : BackendUserAuthentication
- getDispatchActionAttrs() : array<string|int, mixed>
- Returns HTML attributes for client-side `ActionDispatcher` of the "add shortcut" button.
- getLanguageService() : LanguageService
- routeExists() : bool
Properties
$arguments
protected
array<string|int, mixed>
$arguments
= []
List of parameter/value pairs relevant for this shortcut
$copyUrlToClipboard
protected
bool
$copyUrlToClipboard
= true
$disabled
protected
bool
$disabled
= false
$displayName
protected
string
$displayName
= ''
$routeIdentifier
protected
string
$routeIdentifier
= ''
Methods
__toString()
public
__toString() : string
Return values
stringgetDisplayName()
public
getDisplayName() : string
Return values
stringgetGroup()
Returns the group number for this button.
public
getGroup() : int
Groups determine the visual grouping and order of buttons within a position. Lower numbers appear first.
Return values
int —The group number (e.g., 1, 10, 90, 91)
getPosition()
Returns the position where this button should be rendered.
public
getPosition() : string
Return values
string —Either ButtonBar::BUTTON_POSITION_LEFT or ButtonBar::BUTTON_POSITION_RIGHT
getRouteIdentifier()
public
getRouteIdentifier() : string
Return values
stringgetType()
Returns the fully qualified class name as the component type identifier.
public
getType() : string
This is used to identify the specific component type in validation and rendering.
Return values
string —The fully qualified class name (e.g., 'TYPO3\CMS\Backend\Template\Components\Buttons\LinkButton')
isDisabled()
public
isDisabled() : bool
Return values
boolisValid()
Validates whether the component is properly configured and can be rendered.
public
isValid() : bool
Each implementing class defines its own validation rules (e.g., required fields).
Return values
bool —True if the component is valid and can be rendered, false otherwise
render()
Renders the component as an HTML string.
public
render() : string
This method should only be called after validating the component with isValid(). The returned HTML is ready to be output to the browser.
Return values
string —The rendered HTML markup
setArguments()
public
setArguments(array<string|int, mixed> $arguments) : static
Parameters
- $arguments : array<string|int, mixed>
Return values
staticsetCopyUrlToClipboard()
Defines whether the shortcut button should be extended to also allow copying the current URL to the operating systems' clipboard.
public
setCopyUrlToClipboard(bool $copyUrlToClipboard) : static
Parameters
- $copyUrlToClipboard : bool
Return values
staticsetDisabled()
public
setDisabled(bool $disabled) : static
Parameters
- $disabled : bool
Return values
staticsetDisplayName()
public
setDisplayName(string $displayName) : static
Parameters
- $displayName : string
Return values
staticsetRouteIdentifier()
public
setRouteIdentifier(string $routeIdentifier) : static
Parameters
- $routeIdentifier : string
Return values
staticgetBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetDispatchActionAttrs()
Returns HTML attributes for client-side `ActionDispatcher` of the "add shortcut" button.
protected
getDispatchActionAttrs(string $routeIdentifier, string $encodedArguments, string $confirmationText) : array<string|int, mixed>
Parameters
- $routeIdentifier : string
- $encodedArguments : string
- $confirmationText : string
Return values
array<string|int, mixed>getLanguageService()
protected
getLanguageService() : LanguageService
Return values
LanguageServicerouteExists()
protected
routeExists(string $routeIdentifier) : bool
Parameters
- $routeIdentifier : string