Get Free Audit

How To Rewrite Module tpl File Via Your Theme In Prestashop

Apr 4, 2013

1098 Alex Simonchik

How To Rewrite Module tpl File Via Your Theme In Prestashop

We often help find solutions for frequently asked questions on our forum. And one of them is how to customize a template without changing the standard tpl. file. In this article we will explain in details the mechanism of loading templates in Prestashop. To change a module template in your theme you need to create a folder with the module name. This method works for css, tpl and js files. For instance, if you need to change the module file blockcart.tpl without making changes into the source module, you can simply copy the file into this folder: themes/your_theme/modules/blockcart/blockcart.tpl. where your_theme – is your theme name. This method can help you avoid problems when transferring to a new version. But if you are making changes directly into the source file, then your customization can get overridden by the source file from the new version.

Such possibility gives us the function Module::display()

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


Unfortunately, this method will not work with php files. This is especially inconvenient for frontend developers, who need to create new modules, which functionality for 99% matches the source modules, but that are using, for example, a different hook. But, we have managed to find a workaround how it is possible to change a hook in any standard module.  To do this, we need to create a module which will be installed along with the theme. In the install function it creates an object of the required module and performs the function registerHook\unregisterHook. Let’s take the module blocknewproducts as an example, which by default has both hookLeftColumn and hookRightColumn functions but is registered only in the rightColumn hook. Let’s use the below code to move this


Here you can download the ready-to-use example of the module.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *