PrestaShop Documentation, PrestaShop Tutorials

PrestaShop Module Hook and Positions

In PrestaShop, Hooks and Positions are used to control where modules appear and execute on your store.

What is a Hook?

A Hook is a predefined location in PrestaShop where modules can insert content or run code.

Examples:

  • Header
  • Footer
  • Left column
  • Product page
  • Checkout page

A module “hooks” into these positions.

Common hooks:

Hook Name Purpose
displayHeader Add CSS/JS in page header
displayFooter Show content in footer
displayHome Homepage content
displayLeftColumn Left sidebar
displayRightColumn Right sidebar
displayProductExtraContent Extra product tabs/content
displayNav1 Top navigation area
actionProductSave Trigger when product is saved

What is Position?

A Position controls:

  1. Which hook the module uses
  2. The order of modules inside that hook

Example:

Inside displayHome hook:

  1. Slider module
  2. Featured products
  3. Banner module

You can move modules up/down.


Manage Module Positions

Go to:

Back Office → Design → Positions

There you can:

  • Transplant module to another hook
  • Change order
  • Unhook modules
  • Add exceptions

Example Module Hook Code

Basic module registration:

public function install()
{
    return parent::install()
        && $this->registerHook('displayHome')
        && $this->registerHook('displayHeader');
}

Hook function:

public function hookDisplayHome($params)
{
    return $this->display(__FILE__, 'views/templates/hook/home.tpl');
}

Display vs Action Hooks

Display Hooks

Used to show HTML content.

Example:

hookDisplayFooter()

Action Hooks

Used to execute logic.

Example:

hookActionCartSave()

No HTML output required.


Important Hook Locations

Front Office Hooks

Hook Location
displayTop Top section
displayNavFullWidth Navigation
displayHome Homepage
displayFooterBefore Above footer
displayFooter Footer

Product Page Hooks

Hook Usage
displayProductButtons Extra buttons
displayProductAdditionalInfo Product info
displayProductExtraContent Tabs

How to Find Available Hooks

Methods:

1. Enable Hook Display

In config:

define('_PS_DEBUG_PROFILING_', true);

2. Use Hook List

Go to:

Design → Positions

or database table:

ps_hook

Transplanting Module

Example:

Move WhatsApp module from footer to left column:

  1. Go to Positions
  2. Find module
  3. Click “Transplant a module”
  4. Select:
    • Module
    • Hook
    • Exceptions

Hook Naming Convention

Type Example
Display displayHome
Action actionCartSave
Filter filterProductContent

Modern Symfony Hooks (PrestaShop 8/9)

Newer versions support Symfony events and Twig hooks alongside classic hooks.

Example:

{% hook 'displayAdminProductsMainStepLeftColumnMiddle' %}

Best Practices

  • Use correct hook for performance
  • Avoid heavy queries in hooks
  • Cache hook output when possible
  • Use exceptions on unnecessary pages
  • Register only needed hooks

Official developer documentation:

PrestaShop DevDocs – Hooks

PrestaShop Official Website

About zohaibk

We develop useful addons for #E-Commerce and #CRM software to provide extra features.#PrestaShop,#Magento,#SugarCRM,#Vtiger & #Android #apps
View all posts by zohaibk →