Skip to content

Instantly share code, notes, and snippets.

@adrienchretien
Last active March 10, 2021 09:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrienchretien/ec01f5e1612fbab6962027fce62b36bd to your computer and use it in GitHub Desktop.
Save adrienchretien/ec01f5e1612fbab6962027fce62b36bd to your computer and use it in GitHub Desktop.
Add a an action button in the Prestashop admin page header toolbar
<?php
namespace MyModule\Controller;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
class MyAdminController extends FrameworkBundleAdminController
{
// …
public function indexAction()
{
// Here you can override some variables from the /src/PrestaShopBundle/Resources/views/Admin/layout.html.twig
// template (layoutTitle, layoutHeaderToolbarBtn, layoutDisplayType, showContentHeader, headerTabContent,
// enableSidebar and help_link) by adding an associative array as second parameter of the render method.
//
// Seems to work from version 1.7.0.0.
return $this->render('@Modules/mymodule/templates/admin/add.html.twig',[
'layoutHeaderToolbarBtn' => [
'add' => [
'href' => $this->generateUrl('admin_mymodule_add'),
'desc' => $this->trans('New block', 'Modules.MyModule.Admin'),
'icon' => 'add_circle_outline',
],
],
]);
}
// …
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment