Hooks are extension points that allow modules to inject content or execute logic at specific locations in the front office. There are two types:
displayFooter, displayProductActions)actionFrontControllerSetMedia, actionProductOutOfStock)As a theme developer, you mainly work with display hooks. For the full hook system, see Hooks.
The {hook} Smarty function calls a hook and outputs the concatenated HTML returned by all modules attached to it:
{hook h='displayFooter'}
| Parameter | Description |
|---|---|
h |
Hook name (required) |
mod |
Restrict output to a single module by name |
excl |
Exclude specific modules (comma-separated). Not recommended: prefer modules_to_unhook in theme.yml |
Any additional parameters are passed through to the modules:
{* Only output from the "mymodule" module *}
{hook h='displayFooter' mod='mymodule'}
{* Exclude specific modules *}
{hook h='displayFooter' excl='blocknewsletter,ps_emailsubscription'}
{* Pass custom variables to modules *}
{hook h='displayFooterProduct' product=$product category=$category}
Register hooks in your config/theme.yml so they appear in the Back Office and modules can attach to them:
global_settings:
hooks:
custom_hooks:
- name: displayFooterBefore
title: displayFooterBefore
description: Add a widget area above the footer
Modules can also register hooks from PHP using Hook::registerHook('MyCustomHook'). See Hooks in the module documentation for the full module-side API.
modules_to_unhook and modules_to_hook are only applied when the theme is activated. Changes to these keys have no effect on a theme that is already active.Remove modules from hooks using modules_to_unhook:
global_settings:
hooks:
modules_to_unhook:
displayFooter:
- ps_socialfollow
displaySearch:
- ps_searchbar
Attach modules to hooks through modules_to_hook:
global_settings:
hooks:
modules_to_hook:
displayHeaderTop:
- blocklanguages
- blockcurrencies
- blockuserinfo
See Theme structure for the full syntax including prepend, append, and page-specific hooks.
For a visual map of all front-office hooks in the Hummingbird theme, see the hook mapping.