Debugging Smarty Templates

Smarty has a debugging console that allows you to easily examine assigned template variables, included templates and config file variables for the current template.

To enable the debugging console:

   1.Set Smarty $debugging property to true.

      $smarty = new Smarty;
      $smarty->debugging = true;

   2.If the debug console window does not pop up when you load the page, set $debug_tpl property to the path of your debug template. By default, Smarty will look for the “debug.tpl” in SMARTY_DIR. This file is included in Smarty distributions and can be found in library “libs/” folder.

The easiest and quickest way to enable debugging console is by placing a {debug} tag in your templates. It works regardless of the $debugging settings in the php script. However, it only allows you to see all the available variables within the scope of the current template.

Example usage:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: