Februari
13
2006

Smarty Hur: Javascript Debug Mall

UPPDATERING: En hämtade paketet finns här: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Här är den modifierade koden, som arbetar och redo att gå ..

Här är länk där du kan ladda ner nanotree javascript ...
http://nanotree.sourceforge.net/~~V

Ersätt min variabeln {$ Site.framework_pub} lämpligt sätt så att JavaScript och bilder kan laddas korrekt.

Notera även, har jag lagt in ett avsnitt för att hantera användardefinierade debug Vars ... Min debug struktur namnet "_user_debug" och "_user_debug_key"

För mer info om hur detta titta på denna tråd:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31.241

Annars om du inte är intresserad, är det säkert att ta bort det avsnittet från mallen. Du kan också ta bort {if} uttalande som jag brukade svepa avsnittet mallen var.

En annan sak du kanske vill spela med är hur många tecken matas ut som värdet för debug. Håll utkik efter detta och ändra den andra siffran att ändra max tecken utgång: @ debug_print_var: 0:1000

PS Kan någon räkna ut varför jag får ett utrymme ovanför <h3> i rätt cell?

Hoppas att detta hjälper, jag vet att jag gillar det Le

PS För att få hela javascript fungerar behöver du bara ändra raden "var mynanopath =" och kontrollera att den pekar på din publika nanopath katalogen. Man kan ner nanotree paketet från http://sourceforge.net/projects/nanotree/

Här är den uppdaterade koden

Kod:
{*
Smarty Custom DHTML Debug Mall
@ Författare Hielke Hoeve
@ Författare Owen Cole <owenc vid ideamesh dot com>
@ Sedan 2006/02/13 Smarty 2.6.12
@ Paketet Smarty
@ Filnamn debug.tpl
*}

{Assign_debug_info}

<SCRIPT Language=javascript>
var mynanopath = "{$ Site.javascript_path} \ / nanotree \ /";

if (self.name == ") {ldelim}
var title = 'Console';
{Rdelim}
else {ldelim}
var title = 'Console_' + self.name;
{Rdelim}
_smarty_console = window.open ("", title.value, "width = 800, höjd = 600, ändra storlek, rullningslister = 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, marginal: 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} kant: tunna fast svart, {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=\"" + mynanopath + "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 ("* som behövs för att initiera trädet \ n.");
_smarty_console.document.write ("* Och för att ringa showTree (ImagePath). faktiskt visa trädet \ n");
_smarty_console.document.write ("* Alternativt kan detta göras i ett skript blocket vid botten av sidan. \ n");
_smarty_console.document.write ("* Fastän denna metod är något renare \ n.");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("-funktion init () {ldelim} \ n");
_smarty_console.document.write ("container = document.getElementById ('debugtreediv'); \ n");
_smarty_console.document.write ("showTree ('" ^ mynanopath + "'); \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("\ / ** \ n");
_smarty_console.document.write ("* anropas när en användare klickar på en nod. \ n");
_smarty_console.document.write ("* @ param treeNode den TreeNode objekt som har klickat. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("-funktion 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 ("-funktion nodeEdited (treeNode) {ldelim} \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("var closedGif = '" + mynanopath + "bilder \ / folder_closed.gif", \ n ");
_smarty_console.document.write ("var openGif = '" + mynanopath + "bilder \ / folder_open.gif", \ n ");
_smarty_console.document.write ("var pageIcon = '" + mynanopath + "bilder \ / sidan 16 × 16.gif", \ n ");
_smarty_console.document.write ("var userIcon = '" + mynanopath + "bilder \ / user_16 × 16.gif", \ n ");
_smarty_console.document.write ("var helpIcon = '" + mynanopath + "bilder \ / help_16 × 16.gif", \ n ");

{* Skapa * bas nod}
{Tilldela var = räknarvärdet = 0}
_smarty_console.document.write ("rootNode = new TreeNode ({$ räknare} 'Smarty Debug", helpIcon,' Detta är Debug Tree Den ersätter den klassiska versionen av Smarty Debug Console. '); \ n ");
{$ Räknare + +}

{* Skapa nod för Mallen innehåller *}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare} 'ingår mallar och konfigurationsfiler (laddningstiden i sekunder):", pageIcon, "");
_smarty_console.document.write ("<table width=\"100%\">");
{§ name = mallar loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% är even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {avsnitt name = strecksatsen loop = $ _debug_tpls [mallar]. djup} &&& {/ sektion} <font color = {om $ _debug_tpls [mallar]. typen eq "mall"} brunt {elseif $ _debug_tpls [mallar]. typ ekv isset ($ _debug_tpls [mallar] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [mallar] exec_time | string_format. "% 0,5 f"}) {if% templates.index% eq 0} (totalt) {/ if} <\ \ / i> <\ \ / font> {/ if} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{Sectionelse}
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> inga mallar ingår <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Sektion}
_smarty_console.document.write ("<\ \ / table>");
_smarty_console.document.write ("'); \ n");

_smarty_console.document.write ("rootNode.addChild (nod {$ räknare}); \ n");
{$ Räknare + +}

{* Skapa nod för variabler användare debug *}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare}" användare debug variabler: "new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (nod {$ räknare}); \ n");
_smarty_console.document.write ("var förälder = nod {$ räknare}; \ n");
{$ Räknare + +}

{* Skapa underordnade noder för variabler användare debug *}
{§ name = Vars loop = $ _user_debug}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare} '{ldelim} $ {$ _user_debug_key [VARS]} {rdelim}', pageIcon, '{$ _user_debug [VARS] | @ debug_print_var: 0:1000 | Escape: javascript | Escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (nod {$ räknare}); \ n");
{$ Räknare + +}
{Sectionelse}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare}" No User felsökningsinformation tilldelad ", HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (nod {$ räknare}); \ n");
{$ Räknare + +}
{/ Sektion}

{* Skapa nod för mallen variabler *}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare} 'tilldelade mall variabler:" new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (nod {$ räknare}); \ n");
_smarty_console.document.write ("var förälder = nod {$ räknare}; \ n");
{$ Räknare + +}

{* Skapa underordnade noder för Mall variabler *}
{§ name = Vars loop = $ _debug_keys}
{Om $ _debug_keys [VARS]! = 'Det _user_debug "&& $ _debug_keys [VARS]! =' _user_debug_key '}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare} '{ldelim} $ {$ _debug_keys [VARS]} {rdelim}', pageIcon, '{$ _debug_vals [VARS] | @ debug_print_var: 0:1000 | Escape: javascript | Escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (nod {$ räknare}); \ n");
{$ Räknare + +}
{/ If}
{Sectionelse}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare}, 'Inga mall variabler tilldelade", HelpIcon); \ n ");
_smarty_console.document.write ("parent.addChild (nod {$ räknare}); \ n");
{$ Räknare + +}
{/ Sektion}

{* Skapa nod för smarty variabler config fil *}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare} tilldelad config fil variabler (yttre mall omfattning): ', new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (nod {$ räknare}); \ n");
_smarty_console.document.write ("var förälder = nod {$ räknare}; \ n");
{$ Räknare + +}

{* Skapa underordnade noder för smarty variabler config fil *}
{§ name = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare} '{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 (nod {$ räknare}); \ n");
{$ Räknare + +}
{Sectionelse}
_smarty_console.document.write ("var nod {$ räknare} = new TreeNode ({$ räknare}, 'Inga config variabler tilldelade", HelpIcon); \ n ");
_smarty_console.document.write ("parent.addChild (nod {$ räknare}); \ n");
{$ Räknare + +}
{/ Sektion}

_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 & Användarhandbok Felsökningskonsolen <\ / h3>");
_smarty_console.document.write ("<h4> Klicka på variabler i trädet för att få sina innehållet visas i den högra panelen <\ / 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>

tags: ,
postat i Guider , programmering med Owen

Följ kommentarer via RSS Feed | Lämna en kommentar | Trackback URL

Lämna din kommentar

 
© 2008 - 2012 - All Rights Reserved - Ideamesh, Inc. 22 frågor. 0,273 sekunder.