Package

Template Injector: Hook-Free Template Integration

Module content injected into any theme template without manual edits: automatic template scanning, theme-aware resolution, and clean uninstall.

Content where PrestaShop has no hooks

PrestaShop provides hooks at specific locations in theme templates. But sometimes a module needs to inject content exactly where no hook exists, after the product title, inside the category description, between breadcrumbs and the H1.

The Template Injector scans Smarty .tpl files, identifies the right injection points, and places module output there, without requiring any manual template modifications.

How it works

  • Template scanning: parses .tpl files to discover safe injection points (after specific HTML elements, before closing tags, etc.)
  • Theme-aware resolution: handles child themes, template overrides, and parent theme fallbacks. If a child theme overrides a template, the injector targets the override, not the parent.
  • Injection tracking: records what was injected where, so the module can cleanly remove all injections on uninstall without leaving orphaned code in templates
  • Profile management: different injection configurations for different contexts (product page vs. category page vs. CMS page)

Why not just edit templates?

Manual template edits break on theme updates. They're error-prone for non-technical users. They can't be automatically reversed on module uninstall. And they don't work across different themes.

The Template Injector addresses these. It resolves the child theme before the parent, records every modification it makes, and removes them when the module calls its cleanup on uninstall. Whether it can find a safe injection point depends on how the theme is built.

Used by

Installed by Canonical Manager, Gallery Revolution, HTML Blocks and SEO Revolution: modules that need to place content where PrestaShop provides no native hook.

The numbers

  • 2,717 lines of runtime template parsing and injection code
  • Child-theme aware: resolves the child theme first and never edits the parent
  • Clean uninstall: all injections tracked and reversible

← Back to Our Technology Stack

Loading...
Back to top