I’ve been working with PHP for a while, but fairly new to Smarty.
I’m working with Prestashop and I’ve noticed Smarty seems to eat up all PHP errors – when there’s an error in the PHP code, the .tpl file just outputs a blank page. I’ve been trying but I can’t get Smarty to display whatever the PHP code outputs, even if there’s an error.
PHP error reporting is set to show errors.
So, for instance, let’s say this is the example.php file:
<?php
//included classes etc go here, irrelevant for this issue
error_reporting(E_ALL ^ E_NOTICE);
echo obvious wrong syntax"
?>
This file is connected to example.tpl which fits the output in a template block.
Obviously, it should throw an error. How do I make Smarty actually display that error?
To activate debug mode, go to
config/config.inc.phpFind the following lines and chage
offtoonfor the first one and set to true the secondThis will display PHP and SQL errors (this would probably be enough for you to resolve “blank page”).
There is also a blog post on prestashop site about p() and d() methods and how to track exceptions
To activate templates debug in Prestashop version older than 1.5,go to config/smarty.config.inc.php
Find the following line and set it to true
When you refresh your page,
themes/debug.tplshould be rendered.To activate templates debug in Prestashop 1.5+ you can enable Smarty debugging via Admin panel
and set
Always open consolebut console will be opened for everyone ( not good for live site 🙂 )or set
Open console with URL parameter (SMARTY_DEBUG)and add?SMARTY_DEBUGto the end of your URL to see consoleHope this helps.