Smarty Debug Console

Another very interesting Smarty feature that is relevant to template designers is the Debug Console. This is a feature that is totally informational, which can be used to debug problems on your templates. It’s important to note that the Debug Console will only work when the display() function call is used for a template. If the PHP script is using fetch() instead to grab the HTML output, Smarty will not include the Debug Console on that.

In order to enable this feature, you will need to update the index.php script we have created throughout this chapter. Here’s what the new content of index.php is supposed to be:

<?php
include_once(‘libs/Smarty.class.php’);
$smarty = new Smarty;
$smarty->debugging = TRUE;

$departments = array(
    ‘marketing’ => ‘Marketing Department’,
    ‘sales’     => ‘Sales Department’,
    ‘support’   => ‘Customer Service Department’
);
$smarty->assign(‘departments’, $departments);

$smarty->display(index.tpl’);
?>

When the $smarty->debugging flag is set to TRUE, and you open your PHP script on your browser, a pop-up window will be opened automatically with the Debug Console, and it should look like this:

Smarty Debug Console

Make sure that your browser is not blocking pop-up windows from your website; otherwise the Debug Console will never be displayed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.162.247