With PrestaShop 1.7, all module overriding code goes to the modules directory (in your module’s own directory). Every PS 1.7 module developer should be aware of this change (introduced with PR 5020: https://github.com/PrestaShop/PrestaShop/pull/5020).
If your asset override is empty, PrestaShop will load nothing (neither the module one nor your override). This is useful if you want to fully remove this module style and add your own to your compiled
Examples in this page are based on this sample module directory structure:
Overriding templates and assets
With PrestaShop 1.7, here are the folder paths to create in order to override templates and assets:
Compared to what was needed in PrestaShop 1.6, it is much simpler:
Overriding with the ‘include’ method
There is one very important issue that you should be aware of. When loading a template file (for instance ‘moduledemo.tpl’), PrestaShop will look for overriding first, in the following order:
But if your moduledemo.tpl file includes the included-template.tpl file, you will have to override ‘included-template.tpl’ as well, even if you don’t want to modify it (nor to edit the path). This means that every file that an overridden file includes needs to be copy-pasted as-is in order for your override to work properly.
The issue goes both ways: if you want to modify the included-template.tpl file, you will have to override the moduledemo.tpl file that includes it.
PrestaShop 1.7 introduces a new cool way to include files in module templates. By using this method, all the expected rules will be followed:
SmartyDev helps you debug!
PrestaShop 1.7 also introduces our own SmartyDev tool, an Smarty extension which allows you to see the template’s name within your generated HTML markup. This will help debugging a lot, especially because of template override.
Here an example of generated markup with SmartyDev activated:
To use it, simply set the _PS_MODE_DEV_ constant to true in your installation’s /config/defines.inc.php file: add the define(‘_PS_MODE_DEV_’, true); line to that file in order to turn the PrestaShop Developer Mode on, which features SmartyDev.