Hook List

The module system provides two types of hooks: event hooks (PHP callbacks) and display hooks (Smarty template injection points).

Event hooks run PHP code at specific moments (e.g. when an order is placed).
Display hooks render HTML into store templates via {$hooks.hook_name}.

Event Hooks

Register listeners inside your module's boot() method using Module::registerHook(). Only hooks listed in the catalog below are accepted.

Hook Name When It Fires Arguments
smarty.assign During Module::bootstrap() — after all enabled modules are loaded $smarty instance
head.assets When front-end CSS/JS assets are collected via Module::getHeadAssets() &$assets array with css and js keys
footer.html Legacy footer HTML injection (prefer display hooks instead)
admin.menu Admin sidebar menu is built (disabled by default — use module detail page)
order.placed After a new order is successfully created Order data array

Display Hooks

Display hooks are assigned per module in the admin panel and stored in module_display_hooks. Rendered output is available in Smarty templates.

Hook Name Location Smarty Variable
footer Store footer area {$hooks.footer}
header Top bar / header {$hooks.header}
home Home page body {$hooks.home}
home_slider Home page top slider {$hooks.home_slider}
home_promo_slider Home page promo / campaign slider {$hooks.home_promo_slider}
product Product listing context (requires id_product in context) {$hooks.product}
product_detail Product detail page {$hooks.product_detail}
product_tab Product tab button {$hooks.product_tab}
product_tab_content Product tab content panel {$hooks.product_tab_content}
product_inf Product detail info block {$hooks.product_inf}
order_payment Checkout payment step (payment modules) {$hooks.order_payment}
order_confirmation Order confirmation page {$hooks.order_confirmation}
Deferred hooks: product, product_tab, product_tab_content, product_inf, order_payment, and order_confirmation are rendered lazily. Use Module::refreshHook($smarty, $hookName, $context) on the relevant page to populate them.

Declaring Display Hooks in Your Module

In your module class, define which display hooks are supported and which are enabled by default on install:

  • $displayHooks — hook name => description (shown in admin)
  • $defaultDisplayHooks — hooks auto-assigned on install()
  • renderDisplayHook($hook, $context) — returns HTML for the matching assets/templates/front/{hook}.tpl

Assigning Hooks via Admin

Hook assignments are saved with Module::setDisplayHooks($moduleName, $hookNames). Only hooks listed in both $displayHooks and the global display hook catalog are accepted.

PHP
<?php

// ── Event hook: listen when an order is placed ──────────────────
public function boot(): void
{
    Module::registerHook('order.placed', function (array $order): void {
        // e.g. send notification, update external stock, log event
        Logger::info('Order placed: ' . ($order['id_order'] ?? ''));
    });

    Module::registerHook('smarty.assign', function ($smarty): void {
        if ($smarty) {
            $smarty->assign('myModuleEnabled', true);
        }
    });

    Module::registerHook('head.assets', function (array &$assets): void {
        $assets['css'][] = 'https://cdn.example.com/extra.css';
    });
}

// ── Display hooks: declare + render ────────────────────────────
public array $displayHooks = [
    'footer'         => 'Footer block',
    'product_detail' => 'Product detail section',
];

public array $defaultDisplayHooks = ['footer'];

public function renderDisplayHook(string $hook, array $context = []): ?string
{
    return match ($hook) {
        'footer' => $this->renderFrontTemplate('footer', [
            'message' => Settings::get('MY_MODULE_TEXT'),
        ]),
        'product_detail' => $this->renderFrontTemplate('product_detail', [
            'id_product' => $context['id_product'] ?? 0,
        ]),
        default => null,
    };
}
footer.tpl (Display Hook Example)
{* assets/templates/front/footer.tpl *}

<div class="my-module-footer">
    {if $message}
        <p>{$message|escape}</p>
    {/if}
</div>
Refresh a deferred hook on product page
<?php

// Call from product detail controller after $smarty is ready:
Module::refreshHook($smarty, 'product_detail', [
    'id_product' => (int) $product['id_product'],
]);

// Smarty template:
// {$hooks.product_detail}
Register display hooks in module class
<?php

// Minimum setup inside {name}.php:

public array $displayHooks = [
    'footer' => 'Shown in store footer',
];

public array $defaultDisplayHooks = ['footer'];

public function renderDisplayHook(string $hook, array $context = []): ?string
{
    if ($hook !== 'footer') {
        return null;
    }

    return $this->renderFrontTemplate('footer', $context);
}