Februari
13
2006

Smarty Hoe: Javascript Debug Template

UPDATE: Een downloadpakket is hier beschikbaar: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Hier is de gewijzigde code, werken en klaar om te gaan ..

Hier is de link waar u kunt downloaden van de nanotree javascript ...
http://nanotree.sourceforge.net/

Vervang mijn variabele {$ Site.framework_pub} adequaat zodat de javascript en beelden correct kan worden geladen.

Houd er ook rekening mee, heb ik toegevoegd in een gedeelte om de gebruiker gedefinieerde debug vars verwerken ... Mijn debug structuur wordt genoemd '_user_debug' en '_user_debug_key'

Voor meer informatie over hoe u deze blik op deze discussie te voeren:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Anders als je niet geïnteresseerd bent, is het veilig om dat gedeelte te verwijderen uit de sjabloon. Je zou ook de {if} statement ik gebruikt om de var sectiesjabloon wrap te verwijderen.

Een ander ding dat je zou willen om mee te spelen is hoeveel tekens worden uitgevoerd als de waarde voor de debug. Kijk voor deze en wijzigen van het tweede nummer op de max tekens uitgang veranderen: @ debug_print_var: 0:1000

PS Kan iemand erachter te komen waarom ik het krijgen van een ruimte boven de <h3> in de juiste cel?

Hoop dat dit helpt, ik weet dat ik het Glimlach

PS Om alle javascript correct werkt u alleen nodig om de lijn te wijzigen "var mynanopath =" en zorg ervoor dat het wijst op uw openbare nanopath directory. U kunt onderaan de nanotree pakket van http://sourceforge.net/projects/nanotree/

Hier is de bijgewerkte code

Code:
{*
Smarty Custom DHTML Debug Template
@ Author Hielke Hoeve
@ Auteur Owen Cole <owenc bij ideamesh dot com>
@ Sinds 2006/02/13 Smarty 2.6.12
@ Pakket Smarty
@ Filename 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, height = 600, aanpasbare, 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=\"" + 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 ("* Nodig om de boom te initialiseren \ n.");
_smarty_console.document.write ("* En tot toonBoom (ImagePath) noemen;. om daadwerkelijk te laten zien de boom \ n");
_smarty_console.document.write ("* Ook dit kan op een scriptblok onderaan de pagina \ n. ');
_smarty_console.document.write ("* Hoewel deze methode enigszins schoner \ n. ');
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("functie init () {ldelim} \ n");
_smarty_console.document.write ("container = document.getElementById ('debugtreediv'); \ n");
_smarty_console.document.write ("toonBoom (" "+ mynanopath +" ') \ n ");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("\ / ** \ n");
_smarty_console.document.write ("* opgeroepen wanneer een gebruiker klikt op een knooppunt \ n.");
_smarty_console.document.write ("* @ param TreeNode de TreeNode object die zijn aangeklikt \ n.");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("functie 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 ("functie nodeEdited (TreeNode) {ldelim} \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("var closedGif = '" + mynanopath + "images \ / folder_closed.gif'; \ n");
_smarty_console.document.write ("var openGif = '" + mynanopath + "images \ / folder_open.gif'; \ n");
_smarty_console.document.write ("var ToevoegenWebpagina ikoon'Pagina = '" + mynanopath + "images \ / pagina 16 × 16.gif'; \ n");
_smarty_console.document.write ("var fotoboek = '" + mynanopath + "images \ / user_16 × 16.gif'; \ n");
_smarty_console.document.write ("var helpIcon = '" + mynanopath + "images \ / help_16 × 16.gif'; \ n");

{* Maak base knooppunt *}
{Toewijzen var = teller waarde = 0}
_smarty_console.document.write ("rootNode = new TreeNode ({$ teller}, 'Smarty Debug', helpIcon, 'Dit is de Debug Boom Het vervangt de klassieke versie van de Smarty Foutopsporingsconsole.'); \ n");
{$ Teller + +}

{* Knooppunt maken voor sjabloon omvat *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'opgenomen sjablonen & configuratiebestanden (laadtijd in seconden):', ToevoegenWebpagina ikoon'Pagina," ");
_smarty_console.document.write ("<table width=\"100%\">");
{Naam sectie = templates lus = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {section name = streepje lus = $ _debug_tpls [templates]. diepte} &&& {/ section} <font color = {if $ _debug_tpls [templates]. soort eq "template"} brown {elseif $ _debug_tpls [templates]. soort eq isset ($ _debug_tpls [templates] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [templates] exec_time | string_format:. "% .5 f"}) {if% templates.index% eq 0} (totaal) {/ if} <\ \ / i> <\ \ / font> {/ if} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{Sectionelse}
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> geen templates meegeleverd <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Section}
_smarty_console.document.write ('<\ \ / table> ");
_smarty_console.document.write (''); \ n ");

_smarty_console.document.write ("rootNode.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}

{* Maak een knooppunt voor de gebruiker debug variabelen *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'gebruiker debug variabelen:', new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (knooppunt {$ teller}); \ n");
_smarty_console.document.write ("var parent = knooppunt {$ teller}; \ n");
{$ Teller + +}

{* Maak kind knooppunten voor de gebruiker debug variabelen *}
{Naam sectie = vars lus = $ _user_debug}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, '{ldelim} $ {$ _user_debug_key [vars]} {rdelim}', ToevoegenWebpagina ikoon'Pagina, '{$ _user_debug [vars] | @ debug_print_var: 0:1000 | escape: javascript | escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}
{Sectionelse}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'No User Debug Information toegewezen', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}
{/ Section}

{* Maak een knooppunt voor template variabelen *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'toegewezen template variabelen:', new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (knooppunt {$ teller}); \ n");
_smarty_console.document.write ("var parent = knooppunt {$ teller}; \ n");
{$ Teller + +}

{* Maak kind knooppunten voor template variabelen *}
{Naam sectie = vars lus = $ _debug_keys}
{If $ _debug_keys [vars]! = '_user_debug' && $ _debug_keys [Vars]! = '_user_debug_key'}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, '{ldelim} $ {$ _debug_keys [vars]} {rdelim}', ToevoegenWebpagina ikoon'Pagina, '{$ _debug_vals [vars] | @ debug_print_var: 0:1000 | escape: javascript | escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}
{/ If}
{Sectionelse}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'No template variabelen toegewezen', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}
{/ Section}

{* Knooppunt maken voor smarty configuratiebestand variabelen *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'toegewezen configuratiebestand variabelen (buitenste sjabloon scope):', new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (knooppunt {$ teller}); \ n");
_smarty_console.document.write ("var parent = knooppunt {$ teller}; \ n");
{$ Teller + +}

{* Maak kind knooppunten voor smarty configuratiebestand variabelen *}
{Naam sectie = config_vars lus = $ _debug_config_keys}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, '{ldelim} $ {$ _debug_config_keys [config_vars]} {rdelim}', ToevoegenWebpagina ikoon'Pagina, '{$ _debug_config_vals [config_vars] | @ debug_print_var: 0:1000 | escape: javascript | escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}
{Sectionelse}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'No config variabelen toegewezen', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (knooppunt {$ teller}); \ n");
{$ Teller + +}
{/ 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 & Gebruiker Foutopsporingsconsole <\ / h3>");
_smarty_console.document.write ("<h4> Klik op variabelen in de boom om de inhoud weergegeven in het rechter zijpaneel moet <\ / 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: ,
geplaatst in Gidsen , programmeren door Owen

Volg reacties via de RSS Feed | Plaats een reactie | Trackback URL

Laat een reactie achter

© 2008 - 2013 - Alle Rechten Voorbehouden - Ideamesh, Inc 22 queries. 2.006 seconden.