Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print all variables available in a Smarty template

Tags:

php

smarty

How do you print all variables available in the context of a Smarty template? Something like the Django debug trace that lists everything being passed.

Thanks

like image 541
Lorenzo Avatar asked Apr 04 '09 11:04

Lorenzo


People also ask

How do I print a smarty variable?

Variables in Smarty can be either displayed directly or used as arguments for functions, attributes and modifiers, inside conditional expressions, etc. To print a variable, simply enclose it in the delimiters so that it is the only thing contained between them.

How do I assign a variable in smarty?

You can assign a variable to root of the current root tree. The variable is seen by all templates using the same root tree. A global variable is seen by all templates. To access {assign} variables from a php script use getTemplateVars() .


2 Answers

Use {debug} From the manual:

{debug} dumps the debug console to the page. This works regardless of the debug settings in the php script. Since this gets executed at runtime, this is only able to show the assigned variables; not the templates that are in use. However, you can see all the currently available variables within the scope of a template.

$debugging = true must be enabled in your settings or class, and site popups must be unblocked to see the window

like image 85
Aron Rotteveel Avatar answered Oct 05 '22 22:10

Aron Rotteveel


var_dump($Smarty->_tpl_vars); 

From the Smarty code :)

like image 36
Thinker Avatar answered Oct 05 '22 23:10

Thinker