Skip to content

Add dashexample module for the new Symfony dashboard hooks#254

Open
mattgoud wants to merge 1 commit into
PrestaShop:masterfrom
mattgoud:add/dashexample-module
Open

Add dashexample module for the new Symfony dashboard hooks#254
mattgoud wants to merge 1 commit into
PrestaShop:masterfrom
mattgoud:add/dashexample-module

Conversation

@mattgoud

Copy link
Copy Markdown

Description

Adds a new example module, dashexample, that demonstrates how a module integrates with the migrated (Symfony) Back Office Dashboard through its new dedicated hook family.

It is both living documentation of the integration contract and a validation vehicle for the dashboard migration (core issue PrestaShop/PrestaShop#41968).

What it demonstrates

  • Registering on the new dashboard hooks: displayAdminDashboardZoneOne, displayAdminDashboardZoneTwo, displayAdminDashboardToolbar.
  • Rendering hook content through module Twig templates — no Smarty, no HelperForm, no Db::getInstance().
  • Using hook parameters (date_from / date_to).
  • Loading the module's own CSS/JS assets from its hook output — no actionAdminControllerSetMedia, no get_class($this->context->controller) detection.

The README.md explains the legacy-vs-Symfony hook families and how a single module can register on both to support multiple PrestaShop versions.

Requirements

  • PrestaShop 9.2.0+ (introduces the migrated dashboard and its hooks).
  • The dashboard feature flag enabled (Advanced Parameters > New & Experimental Features).

How to test

  1. On a 9.2.0+ shop, enable the dashboard feature flag.
  2. Install the module: php bin/console prestashop:module install dashexample.
  3. Open the Dashboard: the module renders blocks in Zone One and Zone Two, plus a marker in the toolbar area, and its own CSS/JS are loaded.
  4. Disable the flag: the legacy dashboard is unaffected (the module registers only the new hooks).

Related

Registers displayAdminDashboardZoneOne, displayAdminDashboardZoneTwo and
displayAdminDashboardToolbar, rendering content through module Twig templates
(no Smarty, no HelperForm, no Db::getInstance()) and loading its own assets
from its hook output (no actionAdminControllerSetMedia / class-name detection).

Serves as living documentation of the new integration contract and as a
validation vehicle for the migrated dashboard (PrestaShop/PrestaShop#41968).
return parent::install()
&& $this->registerHook([
'displayAdminDashboardZoneOne',
'displayAdminDashboardZoneTwo',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'displayAdminDashboardZoneTwo',
'displayAdminDashboardZoneTwo',
'displayAdminDashboardZoneThree',

An exemple with zone 3 would be nice


{% trans_default_domain 'Module.Dashexample.Admin' %}

{# The module loads its own assets from its hook output — no actionAdminControllerSetMedia,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting to have this alternative as an example, but I don't understand why we hunt the actionAdminControllerSetMedia so badly in this migration. This hook is used widely on every page for any module integration, and it's a common usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants