[ENHANCEMENT] get_template_vars on steroids vs debug
Posted: Fri Sep 26, 2008 3:24 am
Hi folks,
I'm new here so please forgive me if this has been covered elsewhere.
As a noob I noticed i was fairly reliant on the debug and get_template_vars tags to learn about the variables on each page.
The first issue i encountered was the "memory exhausted" message in the debug output whenever debug got to a large object like $gCms, $mod or $feu_smarty.
Not being one to accept defeat, I've implemented a custom version of get_template_vars that exposes more of the template variables' properties. (like array contents)
If you comment out the existing function : smarty_cms_function_get_template_vars
inside the plugins/function.get_template_vars.php
and add the following in it's place, you'll be able to see more info about complex variables used in your pages:
I've also attached a copy of the entire function.get_template_vars.php file for easier installation. (just rename your existing one before uploading it!)
Cheers,
-Damo (aka Grumpy)
I'm new here so please forgive me if this has been covered elsewhere.
As a noob I noticed i was fairly reliant on the debug and get_template_vars tags to learn about the variables on each page.
The first issue i encountered was the "memory exhausted" message in the debug output whenever debug got to a large object like $gCms, $mod or $feu_smarty.
Not being one to accept defeat, I've implemented a custom version of get_template_vars that exposes more of the template variables' properties. (like array contents)
If you comment out the existing function : smarty_cms_function_get_template_vars
inside the plugins/function.get_template_vars.php
and add the following in it's place, you'll be able to see more info about complex variables used in your pages:
Code: Select all
function smarty_cms_function_get_template_vars($params, &$smarty)
{
global $gCms;
$tpl_vars = $gCms->smarty->get_template_vars();
$str = '<div style="overflow: auto; width: 500px; height: 400px;"><pre>';
//$str = print_r($tpl_vars, true);
foreach( $tpl_vars as $key => $value )
{
if( !is_object($value) )
{
$str .= "$key = $value<br/>";
}
else
{
if ($key == 'gCms') {}
else if ($key== 'mod') {}
else if ($key == 'feu_smarty') {}
else
{
$value = print_r($value,true);
$str .= "$key = $value<br/>";
}
}
}
$str .= "</pre></div>";
return $str;
}
Cheers,
-Damo (aka Grumpy)