PrestaShop Debug tip: display template names and path in the front office

In this video we will see how to save hours of debugging, by displaying the name of each template coming from modules in the front office

Watch the screencast

Text Version

Open up Module.php, located in the classes/module/ folder. Reach the display method, and right at the very end, just before the return statement, add the following:

            if($result && _PS_MODE_DEV_ === true)
            {
                $tpl_path = $this->getTemplatePath($template);
                $result = '<!-- START ' . $tpl_path .' -->' . $result . '<!-- END ' . $tpl_path .' -->';    
            }

Save, make sure dev mode is enabled, then refresh the front office. Open up Chrome developer tools (or equivalent) and inspect the section you need of the template, you will see each module’s box wrapped with the corresponding template path

You like the tuts and want to say "thank you"? Well, you can always feel free to donate:

  • Mads Oliver Jenssen

    Thanks alot!
    Is there any way to the same for theme tpl files too?
    Example

Store Top Sales

You like the tuts and want to say "thank you"? Well, you can always feel free to donate: