Skip to content

Commit

Permalink
Update CreateModuleWithExtbase.rst (#5138)
Browse files Browse the repository at this point in the history
Extend the code example how to create links to Extbase controller actions. It is not obvious based on the current documentation, that the array-key of the new module-configuration must be used, plus passing the controller and action name as arguments.

The issue was solved in Slack (thanks Garvin!) and is now added here for future use.
  • Loading branch information
Moongazer authored and linawolf committed Dec 11, 2024
1 parent e9efa02 commit 04d3279
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ After that you can add titles, menus and buttons using :php:`ModuleTemplate`:
{
$this->view->assign('someVar', 'someContent');
$moduleTemplate = $this->moduleTemplateFactory->create($this->request);
// Adding title, menus, buttons, etc. using $moduleTemplate ...
// Example of adding a page-shortcut button
$routeIdentifier = 'web_examples'; // array-key of the module-configuration
$buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
$shortcutButton = $buttonBar->makeShortcutButton()->setDisplayName('Shortcut to my action')->setRouteIdentifier($routeIdentifier);
$shortcutButton->setArguments(['controller' => 'MyController', 'action' => 'my']);
$buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
// Adding title, menus and more buttons using $moduleTemplate ...
$moduleTemplate->setContent($this->view->render());
return $moduleTemplate->renderResponse('MyController/MyAction');
}
Expand Down

0 comments on commit 04d3279

Please sign in to comment.