Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Another Debugger idea.. Collapsable variables..
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
Squee-D
Smarty n00b


Joined: 24 Jun 2003
Posts: 4
Location: Waipu, New Zealand

PostPosted: Thu Jul 03, 2003 1:13 pm    Post subject: Another Debugger idea.. Collapsable variables.. Reply with quote

Ok one more thought on the debugger.. It would be REALLY nice if you could collapse variables, both template variables, and portions of the print_r style value (such as closing up arrays)
_________________
Yours,
Rasheed Abdal-Aziz
System Architect
Simtrek P/L
rasheed@simtrek.com
Back to top
View user's profile Send private message Visit poster's website
Galadhrim
Smarty n00b


Joined: 15 Dec 2003
Posts: 3

PostPosted: Sun Dec 21, 2003 8:36 pm    Post subject: Reply with quote

I second that! I've tried making a plugin, but with the code of the debugger is not really doable.

I'll let you know when i've finished rewriting the code of the debugger.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Dec 24, 2003 7:38 pm    Post subject: Reply with quote

try searching the dev mailing list -- an alternate javascript version with collapsable sections was posted some time ago.
Back to top
View user's profile Send private message
Galadhrim
Smarty n00b


Joined: 15 Dec 2003
Posts: 3

PostPosted: Fri Dec 26, 2003 3:56 pm    Post subject: Reply with quote

boots wrote:
try searching the dev mailing list


Didn't find it on any mailing list. I downloaded all the newsgroups and read about all posts. Found 1 thing so far, but it leads to nothing also:
http://news.php.net/article.php?group=php.smarty.dev&article=1717

Also searched the forums for anything matching debug, console and/or javascript.

Maybe somewhere in the resources...
Back to top
View user's profile Send private message
Galadhrim
Smarty n00b


Joined: 15 Dec 2003
Posts: 3

PostPosted: Fri Dec 26, 2003 4:18 pm    Post subject: Reply with quote

I think i found what you meant, it's just that the link to the example and the code is dead.

http://test3.dgtmedia.com/debug.zip is the link to the code, but its dead.

---
Update:

I've found this thing called nanotree, which is used in the code above. Guess i will have to code something myself... Smile
http://nanotree.sourceforge.net/
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 09, 2004 8:35 pm    Post subject: Reply with quote

Posting this for reference, a promising looking debug console idea...

http://marc.theaimsgroup.com/?l=smarty-dev&m=109767437408797&w=2
Back to top
View user's profile Send private message Visit poster's website
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Fri Jan 06, 2006 1:45 pm    Post subject: Reply with quote

My previous e-mail address expired so posting as a diff user, used to be Galadhrim Embarassed


mohrt wrote:
Posting this for reference, a promising looking debug console idea... http://marc.theaimsgroup.com/?l=smarty-dev&m=109767437408797&w=2


It looks nice, however the installation procedure doesn't work for me and its annoying (maybe newer smarty version?). I don't want to reinstall it every time I patch Smarty.


I have made a first version of a debug console in a tree layout.
The debug console popup doesn't work and I ain't a Javascript expert, since it sucks and is insecure, if anyone can figure out my mistake please point me to it.

I don't get the line
[php:1:20c4a0bc62]{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}[/php:1:20c4a0bc62]
as I cannot find a link to the variable $_smarty_debug_output in any internal file. Anyone? I changed this if statement to be true so that you can see it at the bottom of the page (link below).

The debugging page can be found here: link.
The tree javasript I downloaded can be found here: link. Thanks to Martin Mouritzen.
A picture of the tree here: link
The debug.tpl file is posted below.

As you can see it is quite basic atm and it suffices my desires. Any suggestions would be cool so I can perhaps post it here working and for anyone else to use.

[php:1:20c4a0bc62]{* Smarty *}

{* debug.tpl, last updated version 2.0.1 *}

{assign_debug_info}

{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}

<!-- cut this code out. It works and is the same as below -->

{else}

<SCRIPT language=javascript>
if( self.name == '' ) {ldelim}
var title = 'Console';
{rdelim}
else {ldelim}
var title = 'Console_' + self.name;
{rdelim}
_smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
_smarty_console.document.write("<HTML><HEAD><TITLE>Smarty Debug Console_"+self.name+"</TITLE></HEAD><BODY bgcolor=#ffffff>");
_smarty_console.document.write("<script type='text/javascript' language='Javascript' src='main/javascripts/nanotree.js'></script>");
_smarty_console.document.write("<script type='text/javascript' language='JavaScript'><!--");
_smarty_console.document.write(" showRootNode = true;");
_smarty_console.document.write(" sortNodes = true;");
_smarty_console.document.write(" dragable = false;");

_smarty_console.document.write(" /**");
_smarty_console.document.write(" * Needed to initialize the tree.");
_smarty_console.document.write(" * And to call showTree(imagePath); to actually show the tree.");
_smarty_console.document.write(" * Alternatively this can be done in a script block at the bottom of the page.");
_smarty_console.document.write(" * Though this method is somewhat cleaner.");
_smarty_console.document.write(" */");
_smarty_console.document.write(" function init() {ldelim}");
_smarty_console.document.write(" container = document.getElementById('debugtreediv');");
_smarty_console.document.write(" showTree('main/javascripts/');");
_smarty_console.document.write(" {rdelim}");

_smarty_console.document.write(" /**");
_smarty_console.document.write(" * Called when a user clicks on a node.");
_smarty_console.document.write(" * @param treeNode the TreeNode object which have been clicked.");
_smarty_console.document.write(" */");
_smarty_console.document.write(" function standardClick(treeNode) {ldelim}");
_smarty_console.document.write(" var mytext = document.getElementById('debugtreetextdiv');");
_smarty_console.document.write(" var param = treeNode.getParam();");
_smarty_console.document.write(" mytext.innerHTML = (param == '') ? treeNode.getName() : param;");
_smarty_console.document.write(" {rdelim}");

_smarty_console.document.write(" function nodeEdited(treeNode) {ldelim}");
_smarty_console.document.write(" {rdelim}");

_smarty_console.document.write(" var closedGif = 'main/javascripts/images/folder_closed.gif';");
_smarty_console.document.write(" var openGif = 'main/javascripts/images/folder_open.gif';");
_smarty_console.document.write(" var pageIcon = 'main/javascripts/images/page16x16.gif';");
_smarty_console.document.write(" var userIcon = 'main/javascripts/images/user_16x16.gif';");
_smarty_console.document.write(" var helpIcon = 'main/javascripts/images/help_16x16.gif';");

{assign var=counter value=0}
_smarty_console.document.write(" rootNode = new TreeNode({$counter},'Debug Tree', helpIcon, 'This is the Debug Tree. It replaces the classical version of the Smarty Debug Console');");
{$counter++}

_smarty_console.document.write(" var node{$counter} = new TreeNode({$counter}, 'included templates & config files (load time in seconds):', new Array(closedGif,openGif));");
_smarty_console.document.write(" rootNode.addChild(node{$counter});");

_smarty_console.document.write(" var parent = node{$counter};");
{$counter++}

{section name=templates loop=$_debug_tpls}
_smarty_console.document.write(" var node{$counter} = new TreeNode( {$counter}, '{$_debug_tpls[templates].filename|escape:html}', {if $_debug_tpls[templates].type eq "template"}pageIcon{elseif $_debug_tpls[templates].type eq "insert"}userIcon{else}helpIcon{/if}, '{if isset($_debug_tpls[templates].exec_time)}Execution time: {$_debug_tpls[templates].exec_time|string_format:"%.5f"}{if %templates.index% eq 0} (total){/if}{/if}' );");
_smarty_console.document.write(" parent.addChild(node{$counter});");
{$counter++}
{sectionelse}
_smarty_console.document.write(" var node{$counter} = new TreeNode( {$counter}, 'No templates included', HelpIcon );");
_smarty_console.document.write(" parent.addChild(node{$counter});");
{$counter++}
{/section}

_smarty_console.document.write(" var node{$counter} = new TreeNode({$counter}, 'assigned template variables:', new Array(closedGif,openGif) );");
_smarty_console.document.write(" rootNode.addChild(node{$counter});");
_smarty_console.document.write(" parent = node{$counter};");
{$counter++}

{section name=vars loop=$_debug_keys}
_smarty_console.document.write(" var node{$counter} = new TreeNode( {$counter}, '{ldelim}${$_debug_keys[vars]}{rdelim}', pageIcon, '{$_debug_vals[vars]|@debug_print_var}' );");
_smarty_console.document.write(" parent.addChild(node{$counter});");
{$counter++}
{sectionelse}
_smarty_console.document.write(" var node{$counter} = new TreeNode( {$counter}, 'No template variables assigned', HelpIcon );");
_smarty_console.document.write(" parent.addChild(node{$counter});");
{$counter++}
{/section}

_smarty_console.document.write(" var node{$counter} = new TreeNode({$counter}, 'assigned config file variables (outer template scope):', new Array(closedGif,openGif) );");
_smarty_console.document.write(" rootNode.addChild(node{$counter});");
_smarty_console.document.write(" parent = node{$counter};");
{$counter++}

{section name=config_vars loop=$_debug_config_keys}
_smarty_console.document.write(" var node{$counter} = new TreeNode( {$counter}, '{ldelim}${$_debug_config_keys[config_vars]}{rdelim}', pageIcon, '{$_debug_config_vals[config_vars]|@debug_print_var}' );");
_smarty_console.document.write(" parent.addChild(node{$counter});");
{$counter++}
{sectionelse}
_smarty_console.document.write(" var node{$counter} = new TreeNode( {$counter}, 'No config variables assigned', HelpIcon );");
_smarty_console.document.write(" parent.addChild(node{$counter});");
{$counter++}
{/section}

_smarty_console.document.write("--></script>");

_smarty_console.document.write("<table border=0 width=100% id=debugtreetable><tr>");
_smarty_console.document.write("<td valign='top' style='width: 250px;'><div id='debugtreediv'></div></td>");
_smarty_console.document.write("<td valign='top'><div id='debugtreetextdiv'></td>");
_smarty_console.document.write("</tr></table>");
_smarty_console.document.write("</BODY></HTML>");
_smarty_console.document.close();
</SCRIPT>

{/if}[/php:1:20c4a0bc62]
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Thu Jan 26, 2006 9:35 pm    Post subject: Reply with quote

I like the idea, but it is not working on this end, using Smarty 2.6.12 and PHP 5.1.1
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Sat Jan 28, 2006 10:57 am    Post subject: Reply with quote

As stated in my previous post the code above doesn't work Confused And I wanted to see if anyone could figure out my error.

Unfortunately I've only been able to get the debug tree working on the same page as the smarty output. The javascript "document.write" wont let me make a new window that includes a <script> tag. Like the code above...

I might even try and make a javascript myself Surprised Which doesn't change the view of the debug console but merely allows collapsing.

For now I only have been able to use this debug.tpl. It puts the debug tree under your smarty output, like with the screenshot i provided in my previous post.
Code:
{* Smarty *}

{* debug.tpl, last updated version 2.0.1 *}

{assign_debug_info}

{if !isset($_smarty_debug_output) and $_smarty_debug_output neq "html"}
   <br><br><br><br>
   
   <script type="text/javascript" language="Javascript" src="main/javascripts/nanotree.js"></script>
   <script type="text/javascript" language="JavaScript">
   <!--
      showRootNode = true;
      sortNodes = true;
      dragable = false;

      /**
       * Needed to initialize the tree.
       * And to call showTree(imagePath); to actually show the tree.
       * Alternatively this can be done in a script block at the bottom of the page.
       * Though this method is somewhat cleaner.
       */
      function init() {ldelim}
         container = document.getElementById('debugtreediv');
         showTree('main/javascripts/');
      {rdelim}

      /**
       * Called when a user clicks on a node.
       * @param treeNode the TreeNode object which have been clicked.
       */
      function standardClick(treeNode) {ldelim}
         var mytext = document.getElementById('debugtreetextdiv');
         var param = treeNode.getParam();
         mytext.innerHTML = (param == '') ? treeNode.getName() : param;
      {rdelim}

      function nodeEdited(treeNode) {ldelim}
      {rdelim}

      var closedGif = 'main/javascripts/images/folder_closed.gif';
      var openGif   = 'main/javascripts/images/folder_open.gif';
      var pageIcon  = 'main/javascripts/images/page16x16.gif';
      var userIcon  = 'main/javascripts/images/user_16x16.gif';
      var helpIcon  = 'main/javascripts/images/help_16x16.gif';

      {assign var=counter value=0}
      rootNode = new TreeNode({$counter},'Debug Tree', helpIcon, 'This is the Debug Tree. It replaces the classical version of the Smarty Debug Console');
      {$counter++}

      var node{$counter} = new TreeNode({$counter}, 'included templates & config files (load time in seconds):', new Array(closedGif,openGif));
      rootNode.addChild(node{$counter});

      var parent = node{$counter};
      {$counter++}

         {section name=templates loop=$_debug_tpls}
            var node{$counter} = new TreeNode(   {$counter},
                           '{$_debug_tpls[templates].filename|escape:html}',
                           {if $_debug_tpls[templates].type eq "template"}pageIcon{elseif $_debug_tpls[templates].type eq "insert"}userIcon{else}helpIcon{/if},
                           '{if isset($_debug_tpls[templates].exec_time)}Execution time: {$_debug_tpls[templates].exec_time|string_format:"%.5f"}{if %templates.index% eq 0} (total){/if}{/if}'
                     );
            parent.addChild(node{$counter});
            {$counter++}
         {sectionelse}
            var node{$counter} = new TreeNode(   {$counter},
                           'No templates included',
                           HelpIcon
                     );
            {$counter++}
         {/section}         

      var node{$counter} = new TreeNode({$counter}, 'assigned template variables:', new Array(closedGif,openGif));
      rootNode.addChild(node{$counter});

      parent = node{$counter};
      {$counter++}

         {section name=vars loop=$_debug_keys}
            var node{$counter} = new TreeNode(   {$counter},
                           '{ldelim}${$_debug_keys[vars]}{rdelim}',
                           pageIcon,
                           "{$_debug_vals[vars]|@debug_print_var}"
                     );
            parent.addChild(node{$counter});
            {$counter++}
         {sectionelse}
            var node{$counter} = new TreeNode(      {$counter},
                                                                        'No template variables assigned',
                                                                        HelpIcon
                                                        );
                                {$counter++}
         {/section}

      var node{$counter} = new TreeNode({$counter}, 'assigned config file variables (outer template scope):', new Array(closedGif,openGif));
      rootNode.addChild(node{$counter});

      parent = node{$counter};
                {$counter++}

                        {section name=config_vars loop=$_debug_config_keys}
                                var node{$counter} = new TreeNode(      {$counter},
                                                                        '{ldelim}${$_debug_config_keys[config_vars]}{rdelim}',
                                                                        pageIcon,
                                                                        "{$_debug_config_vals[config_vars]|@debug_print_var}"
                                                        );
                                parent.addChild(node{$counter});
                                {$counter++}
                        {sectionelse}
                                var node{$counter} = new TreeNode(      {$counter},
                                                                        'No config variables assigned',
                                                                        HelpIcon
                                                        );
                                {$counter++}
                        {/section}
      -->
   </script>

   <table border=0 width=100% id=debugtreetable>
      <tr>
         <td valign="top" style="width: 250px;">
            <div id="debugtreediv"></div>
         </td>
         <td valign="top">
            <div id="debugtreetextdiv">
         </td>
      </tr>
   </table>
</BODY></HTML>

{else}

<!-- same code as the code quote in previous post -->

{/if}
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Mon Feb 13, 2006 6:21 pm    Post subject: Reply with quote

I think I figured out the problem with the debug.tpl you posted with the nanotree.js script.

It looks like the reason you weren't able to get the script to execute in the popup was because you didn't escape all your slashes correctly...

I will come back and post the results once I'm done testing everything and prettying it up a bit.
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Mon Feb 13, 2006 7:05 pm    Post subject: Reply with quote

Here is the modified code, working and ready to go..

Here is the link where you can download the nanotree javascript...
http://nanotree.sourceforge.net/

Replace my variable {$Site.framework_pub} appropriately so that the javascript and images can be loaded correctly.

Also please note, I have added in a section to handle user defined debug vars... My debug structure is named '_user_debug' and '_user_debug_key'

For more info on how to implement this look at this thread :
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=3127

Otherwise if you aren't interested, it is safe to remove that section from the template. You could also remove the {if} statement I used to wrap the template var section.

Another thing you might want to play with is how many characters are output as the value for debug. Look for this and modify the second number to alter the max chars output :@debug_print_var:0:1000

PS Can anyone figure out why I am getting a space above the <h3> in the right cell?

Hope this helps, I know I like it Smile

Code:

{*
   Smarty Custom DHTML Debug Template
   @author Hielke Hoeve
   @author Owen Cole <owenc at totalsales dot com>
   @since 02/13/2006 Smarty 2.6.12
   @package Smarty
   @filename debug.tpl
*}

{assign_debug_info}

<SCRIPT language=javascript>
   if( self.name == '' ) {ldelim}
      var title = 'Console';
   {rdelim}
   else {ldelim}
      var title = 'Console_' + self.name;
   {rdelim}
   _smarty_console = window.open("",title.value,"width=800,height=600,resizable,scrollbars=yes");
   _smarty_console.document.write("<html><head><title>Smarty Debug Console_"+self.name+"<\/title>\n");
   _smarty_console.document.write("<style>\n");
   _smarty_console.document.write("h3 {ldelim}padding : 5px 5px 5px 5px; margin 0px 0px 0px 0px; background-color : #cccccc;{rdelim}\n");
   _smarty_console.document.write("#debugtreetable {ldelim}width : 100%;{rdelim} \n");
   _smarty_console.document.write("#debugtreetable td {ldelim}border : thin solid black;{rdelim} \n");
   _smarty_console.document.write("#debugtreetextdiv div {ldelim}padding-left : 10px;{rdelim} \n");
   _smarty_console.document.write("<\/style>\n");
   _smarty_console.document.write("<script language=\"Javascript\" src=\"{$Site.framework_pub}\/javascript\/nanotree\/nanotree.js\"><\/script>\n");
   _smarty_console.document.write("<script type=\"text\/javascript\" language=\"JavaScript\">\n");
   _smarty_console.document.write("<!--\n");
   _smarty_console.document.write("   showRootNode = true;\n");
   _smarty_console.document.write("   sortNodes = 0;\n");   
   _smarty_console.document.write("   dragable = false;\n");
   _smarty_console.document.write("   showAllNodesOnStartup = true;\n");

   _smarty_console.document.write("   \/**\n");
   _smarty_console.document.write("    * Needed to initialize the tree.\n");
   _smarty_console.document.write("    * And to call showTree(imagePath); to actually show the tree.\n");
   _smarty_console.document.write("    * Alternatively this can be done in a script block at the bottom of the page.\n");
   _smarty_console.document.write("    * Though this method is somewhat cleaner.\n");
   _smarty_console.document.write("    *\/\n");
   _smarty_console.document.write("   function init() {ldelim}\n");
   _smarty_console.document.write("      container = document.getElementById('debugtreediv');\n");
   _smarty_console.document.write("      showTree('{$Site.framework_pub}\/javascript\/nanotree\/');\n");
   _smarty_console.document.write("   {rdelim}\n");

   _smarty_console.document.write("   \/**\n");
   _smarty_console.document.write("    * Called when a user clicks on a node.\n");
   _smarty_console.document.write("    * @param treeNode the TreeNode object which have been clicked.\n");
   _smarty_console.document.write("    *\/\n");
   _smarty_console.document.write("   function standardClick(treeNode) {ldelim}\n");
   _smarty_console.document.write("      var mytext = document.getElementById('debugtreetextdiv');\n");
   _smarty_console.document.write("      var param = treeNode.getParam();\n");
   _smarty_console.document.write("      mytext.innerHTML = (param == '') ? treeNode.getName() : '<h3>' + treeNode.getName() + '<\/h3><div>' + param + '<\/div>';\n");
   _smarty_console.document.write("   {rdelim}\n");

   _smarty_console.document.write("   function nodeEdited(treeNode) {ldelim}\n");
   _smarty_console.document.write("   {rdelim}\n");

   _smarty_console.document.write("   var closedGif = '{$Site.framework_pub}\/javascript\/nanotree\/images\/folder_closed.gif';\n");
   _smarty_console.document.write("   var openGif   = '{$Site.framework_pub}\/javascript\/nanotree\/images\/folder_open.gif';\n");
   _smarty_console.document.write("   var pageIcon  = '{$Site.framework_pub}\/javascript\/nanotree\/images\/page16x16.gif';\n");
   _smarty_console.document.write("   var userIcon  = '{$Site.framework_pub}\/javascript\/nanotree\/images\/user_16x16.gif';\n");
   _smarty_console.document.write("   var helpIcon  = '{$Site.framework_pub}\/javascript\/nanotree\/images\/help_16x16.gif';\n");

{* Create base node *}
                              {assign var=counter value=0}
   _smarty_console.document.write("   rootNode = new TreeNode({$counter},'Smarty Debug', helpIcon, 'This is the Debug Tree. It replaces the classical version of the Smarty Debug Console');\n");
                              {$counter++}

{* Create node for template includes *}
   _smarty_console.document.write("   var node{$counter} = new TreeNode({$counter}, 'included templates & config files (load time in seconds):', pageIcon, '");
      _smarty_console.document.write("<table width=\"100%\">");
   {section name=templates loop=$_debug_tpls}
      _smarty_console.document.write("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth}&&&{/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html|escape:javascript}</font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>");
   {sectionelse}
      _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>");   
   {/section}
      _smarty_console.document.write("<\/table>");
   _smarty_console.document.write("');\n");

   _smarty_console.document.write("   rootNode.addChild(node{$counter});");
                              {$counter++}

{* Create node for user debug variables *}
   _smarty_console.document.write("   var node{$counter} = new TreeNode({$counter}, 'user debug variables:', new Array(closedGif,openGif) );\n");
   _smarty_console.document.write("   rootNode.addChild(node{$counter});\n");
   _smarty_console.document.write("   parent = node{$counter};\n");
                              {$counter++}

{* Create child nodes for user debug variables *}
                              {section name=vars loop=$_user_debug}
   _smarty_console.document.write("      var node{$counter} = new TreeNode( {$counter}, '{ldelim}${$_user_debug_key[vars]}{rdelim}', pageIcon, '{$_user_debug[vars]|@debug_print_var:0:1000|escape:javascript|escape:javascript}' );");
   _smarty_console.document.write("      parent.addChild(node{$counter});");
                                 {$counter++}
                              {sectionelse}
   _smarty_console.document.write("      var node{$counter} = new TreeNode(   {$counter}, 'No User Debug Information assigned', HelpIcon );\n");
   _smarty_console.document.write("      parent.addChild(node{$counter});\n");
                                         {$counter++}
                              {/section}

{* Create node for template variables *}
   _smarty_console.document.write("   var node{$counter} = new TreeNode({$counter}, 'assigned template variables:', new Array(closedGif,openGif) );\n");
   _smarty_console.document.write("   rootNode.addChild(node{$counter});\n");
   _smarty_console.document.write("   parent = node{$counter};\n");
                              {$counter++}

{* Create child nodes for template variables *}
                              {section name=vars loop=$_debug_keys}
                                    { if $_debug_keys[vars] != '_user_debug' && $_debug_keys[vars] != '_user_debug_key' }
   _smarty_console.document.write("      var node{$counter} = new TreeNode( {$counter}, '{ldelim}${$_debug_keys[vars]}{rdelim}', pageIcon, '{$_debug_vals[vars]|@debug_print_var:0:1000|escape:javascript|escape:javascript}' );");
   _smarty_console.document.write("      parent.addChild(node{$counter});");
                                 {$counter++}
                                     {/if}
                              {sectionelse}
   _smarty_console.document.write("      var node{$counter} = new TreeNode(   {$counter}, 'No template variables assigned', HelpIcon );\n");
   _smarty_console.document.write("      parent.addChild(node{$counter});\n");
                                         {$counter++}
                              {/section}

{* Create node for smarty config file variables *}
   _smarty_console.document.write("   var node{$counter} = new TreeNode({$counter}, 'assigned config file variables (outer template scope):', new Array(closedGif,openGif) );\n");
   _smarty_console.document.write("   rootNode.addChild(node{$counter});\n");
   _smarty_console.document.write("   parent = node{$counter};\n");
                                  {$counter++}

{* Create child nodes for smarty config file variables *}
                                    {section name=config_vars loop=$_debug_config_keys}
    _smarty_console.document.write("       var node{$counter} = new TreeNode( {$counter}, '{ldelim}${$_debug_config_keys[config_vars]}{rdelim}', pageIcon,  '{$_debug_config_vals[config_vars]|@debug_print_var:0:1000|escape:javascript|escape:javascript}' );\n");
    _smarty_console.document.write("        parent.addChild(node{$counter});\n");
                                         {$counter++}
                                    {sectionelse}
    _smarty_console.document.write("      var node{$counter} = new TreeNode( {$counter}, 'No config variables assigned', HelpIcon );\n");
   _smarty_console.document.write("      parent.addChild(node{$counter});\n");
                                         {$counter++}
                                    {/section}

   _smarty_console.document.write("\/\/-->\n");
   _smarty_console.document.write("<\/script>\n\n");
   _smarty_console.document.write("<\/head><body onload=\"init()\">\n");
   _smarty_console.document.write("<h3>Smarty & User Debug Console<\/h3>");
   _smarty_console.document.write("<h4>Click on variables in the tree to have their contents displayed in the right side panel.<\/h4>");
   _smarty_console.document.write("<table border='0' id='debugtreetable'><tr>");
   _smarty_console.document.write("<td valign='top' style='width: 250px;'><div id='debugtreediv'>&<\/div><\/td>");
   _smarty_console.document.write("<td valign='top'><div id='debugtreetextdiv'>&<\/td>");
   _smarty_console.document.write("<\/tr><\/table>");
   _smarty_console.document.write("<\/body><\/html>");
   _smarty_console.document.close();
</SCRIPT>

_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template


Last edited by TGKnIght on Tue Feb 14, 2006 5:35 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Feb 14, 2006 5:07 pm    Post subject: Reply with quote

I have made a fix to the debug.tpl I posted yesterday... Basically the problem was if any of the variables contained strings that had single quotes, it would would only be escaped for the first javascript, not in the javascript that is generated in the popup panel.

Double escaping javascript characters seems to do the trick. To resolve this I have changed the modifiers list for the variable output to look like so :

Code:

{$_debug_vals[vars]|@debug_print_var:0:1000|escape:javascript|escape:javascript}


This will need to be applied to all three output sections.. Not neccessary AFAIK for the template times..

I have modified the posted code above with the appropriate changes.
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Tue Feb 14, 2006 6:52 pm    Post subject: Reply with quote

woah cool, i did check escaping quotes, but should have figured i had to do double escaping. Thanks for the tip, i will sure try your code. Perhaps make a somewhat more configurable version. Twisted Evil
_________________
Debug XHTML Compliance
SmartyPaginate
Smarty License Questions
---
(About Unix) The learning curve is full of aha! moments, such as that glorious day that the full beauty of grep and, later, find is revealed in all its majesty. --- Robert Uhl <ruhl@4dv.net>
Back to top
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Feb 14, 2006 7:40 pm    Post subject: Reply with quote

That's cool... I was thinking of turning it into a full blown debug add-on class for Smarty...

Provide the standard method for inserting user-debugs to the template, setup some default debugs such as the superglobals $_POST, $_SERVER etc...

Setup the pointer to the new template automatically, etc...

Let me know what you think.. and what else can be done to make the template easier to configure.
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Tue Feb 14, 2006 9:06 pm    Post subject: Reply with quote

TGKnIght wrote:
That's cool... I was thinking of turning it into a full blown debug add-on class for Smarty...

Provide the standard method for inserting user-debugs to the template, setup some default debugs such as the superglobals $_POST, $_SERVER etc...

Me too, but wanted to do it in steps Smile At the other hand it might save time to make one immediately.

At the moment I assign debug vars to $_DEBUG and then assign $_DEBUG to smarty, making it come up in the tree. Haven't really investigated other possibilities... Perhaps using a variable to tell the debug window what the names of the debug vars are?

TGKnIght wrote:
Setup the pointer to the new template automatically, etc...

That could be handy, perhaps just a simple variable that would make the addon show the custom template or the default template. Allowing every instance of smarty choose it's own debug template. Don't like the javascript very much (in general) but in this case we have no choice but to make it write a popup... Crying or Very sad
_________________
Debug XHTML Compliance
SmartyPaginate
Smarty License Questions
---
(About Unix) The learning curve is full of aha! moments, such as that glorious day that the full beauty of grep and, later, find is revealed in all its majesty. --- Robert Uhl <ruhl@4dv.net>
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP