| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Demonstration module for the migrated (Symfony) Back Office Dashboard and its new dedicated hook family.
It is both living documentation of the integration contract and a validation vehicle: once installed with the dashboard feature flag enabled, it renders content in every zone of the new dashboard page, including four Chart.js charts (doughnut, line, bar, polar area).
# from the PrestaShop root
php bin/console prestashop:module install dashexampleThen enable the dashboard feature flag and open the Dashboard. You should see the module's cards in every zone (four charts across the three columns) and a marker in the toolbar area.
The dashboard page loads Chart.js v4 as an independent core bundle (themes/new-theme/public/chartjs.bundle.js) — only on that page, not in the main Back Office bundle. It exposes two globals:
A chart whose datasets define no color at all is colored automatically with the PrestaShop palette (the core replaces the default Chart.js colors plugin) — see the Zone One doughnut. A chart that defines any color is left untouched, so pick every color from psChart explicitly when some series need a specific meaning — see the Zone Two line chart (previous period in neutral gray) and bar chart.
Keep legends and tooltips enabled (Chart.js defaults) so series identity never relies on color alone, and give each <canvas> a role="img" and an aria-label — canvases are invisible to screen readers.
The migrated dashboard deliberately uses a new hook family, distinct from the legacy one. A module knows which architecture it is integrating with purely from which hook is called — there is no version detection to do on the module side.
| New (Symfony dashboard) | Legacy (legacy dashboard) | Area |
|---|---|---|
| displayAdminDashboardZoneOne | dashboardZoneOne | Left column |
| displayAdminDashboardZoneTwo | dashboardZoneTwo | Center column |
| displayAdminDashboardZoneThree | dashboardZoneThree | Right column |
| displayAdminDashboardTop | displayDashboardTop | Top area |
| displayAdminDashboardToolbar | displayDashboardToolbarTopMenu | Toolbar |
The legacy hooks are untouched and keep working on the legacy page (flag off).
To render on both the legacy and the migrated dashboard from a single module, register on both hook families and let each callback render with the matching architecture. The core calls only the hook that belongs to the currently displayed page, so the two never collide.
public function install(): bool
{
return parent::install()
&& $this->registerHook([
// Migrated (Symfony) dashboard — Twig, no legacy helpers
'displayAdminDashboardZoneOne',
'displayAdminDashboardZoneTwo',
'displayAdminDashboardToolbar',
// Legacy dashboard — Smarty / HelperForm as before
'dashboardZoneOne',
'dashboardZoneTwo',
'displayDashboardToolbarTopMenu',
]);
}
// Called only on the migrated page
public function hookDisplayAdminDashboardZoneOne(array $params): string
{
return $this->get('twig')->render('@Modules/mymodule/views/templates/admin/zone_one.html.twig', $params);
}
// Called only on the legacy page
public function hookDashboardZoneOne(array $params): string
{
// legacy Smarty rendering
$this->smarty->assign($params);
return $this->display(__FILE__, 'views/templates/hook/zone_one.tpl');
}This module registers only the new hooks on purpose, so it also serves as a focused test of the new contract.
| File | Role |
|---|---|
| dashexample.php | Module class: hook registration + hook callbacks rendering Twig |
| views/templates/admin/zone_one.html.twig | Zone One card: traffic-sources doughnut (auto-colored) |
| views/templates/admin/zone_two.html.twig | Zone Two cards: sales-trend line + monthly-goals bar (explicit palette tokens) |
| views/templates/admin/zone_three.html.twig | Zone Three card: orders-by-status polar area (auto-colored) |
| views/templates/admin/top.html.twig | Top area banner |
| views/templates/admin/bottom.html.twig | Full-width bottom card |
| views/templates/admin/toolbar.html.twig | Toolbar marker badge |
| views/js/zone-one.js, views/js/zone-two.js, views/js/zone-three.js | Per-zone chart initialization (each loaded by its own hook template) |
| views/css/dashexample.css | Module-owned styles |
| Back | FazBrowse Home | New Git URL |