Február
13
2006

Smarty: Hogyan lehet Javascript Debug Sablon

UPDATE: A letölthető csomag itt érhető el: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Itt a módosított kódot, a munka, és kész ..

Itt a link, ahol lehet letölteni a nanotree javascript ...
http://nanotree.sourceforge.net/~~V

Cserélje ki a változó} {$ Site.framework_pub megfelelően úgy, hogy a javascript, és képeket lehet betölteni.

Figyeljünk, adtam hozzá egy részében kezelni a felhasználó által meghatározott hibakeresési vars ... Saját hibakeresési szerkezet neve "_user_debug" és a "_user_debug_key"

További információk arról, hogyan kell ezt nézd meg ezt a téma:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Különben, ha nem érdekel, hogy biztonságosan eltávolítani, hogy részben a sablont. Azt is vegye ki a nyilatkozatát} {if szoktam betakar a sablon var részt.

A másik dolog, amit érdemes játszani, hogy hány karakter van, mint a kimeneti érték debug. Keresse meg ezt, és módosítsa a második számot megváltoztatni a max karakter kimenet: @ debug_print_var: 0:1000

PS Tud valaki kitalálni, hogy miért kapok helyet fölött <h3> a megfelelő cellába?

Remélem ez segít, tudom, hogy tetszik Mosolyog

PS, hogy minden megfelelően működik a javascript csak akkor kell módosítani a vonal "mynanopath var =" és győződjön meg róla, hogy felhívja a közvélemény nanopath könyvtárban. Tudod le a csomagot nanotree http://sourceforge.net/projects/nanotree/

Itt a frissített kódot

Kód:
{*
Egyéni DHTML Smarty Debug Sablon
@ Author Hielke Hoeve
@ Szerző Owen Cole <owenc at ideamesh dot com>
@ 2006/02/13 óta Smarty 2.6.12
@ Smarty csomag
@ Filename debug.tpl
*}

{} Assign_debug_info

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

if (self.name == ") {} ldelim
var title = 'Konzol';
{} Rdelim
else {} ldelim
var title = 'Console_' + self.name;
{} Rdelim
_smarty_console = window.open ("", title.value, "width = 800, height = 600, átméretezhető, görgetősávok = 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 szélesség: 100%;} {rdelim \ n");
_smarty_console.document.write ("# debugtreetable td {} ldelim határ: az egyszínű fekete vékony;} {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 ("* Szükséges inicializálni a fát. \ n");
_smarty_console.document.write ("* És hogy hívják showTree (ImagePath) mutatja, hogy ténylegesen a fa. \ n");
_smarty_console.document.write ("* Vagy lehet ezt tenni egy script blokk alján található az oldalon. \ n");
_smarty_console.document.write ("* Bár ez a módszer valamivel tisztább. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("funkció init () {} ldelim \ n");
_smarty_console.document.write ("konténerszállító = 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 ("* meghívásra, ha a felhasználó rákattint egy csomópontra. \ n");
_smarty_console.document.write ("* @ param treeNode a TreeNode tárgyat, amelyeket kattintott. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("funkció 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 = (p ==")? treeNode.getName (): "<h3>" treeNode.getName + () + '<\ / h3> <div>' + p + ' <\ / div> '; \ n ");
_smarty_console.document.write ("{} rdelim \ n");

_smarty_console.document.write ("funkció 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 pageIcon = '" + + mynanopath "images \ / 16. oldalon olvashat × 16.gif" \ n ");
_smarty_console.document.write ("var userIcon = '" + + mynanopath "images \ / user_16 × 16.gif" \ n ");
_smarty_console.document.write ("var helpIcon = '" + + mynanopath "images \ / help_16 × 16.gif" \ n ");

{* Bázis létrehozása node *}
{Var hozzá = számláló értéke = 0}
_smarty_console.document.write ("rootNode = new TreeNode ({} $ counter," Smarty debug ', helpIcon,' Ez a Debug fa. Ez helyettesíti a klasszikus változata a Smarty Debug Console ") \ n");
{$ Counter + +}

{* Csomópont létrehozása sablon *}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," benne sablonok és konfigurációs fájlok (terhelési idő másodpercben): "pageIcon," ");
_smarty_console.document.write ("<table width=\"100%\">");
{Name = részben sablonok loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% van even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {name = részben franciabekezdése loop = $ _debug_tpls [templates]. mélység} {&&& / szakasz} <font color = $ {if _debug_tpls [templates]. típusú eq "sablon"} {elseif $ barna _debug_tpls [templates]. típusú eq isset ($ _debug_tpls [templates]. exec_time)} <font size=-1> <i> ({$ _debug_tpls [templates]. exec_time | string_format: "0,5% f"}) {if% templates.index% eq 0} (összes) {/ if} <\ \ / i> <\ \ / font> {/ if} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{} Sectionelse
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> nincs benne sablon <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Rész}
_smarty_console.document.write ("<\ \ / table>");
_smarty_console.document.write (""); \ n ");

_smarty_console.document.write ("rootNode.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}

{* Új csomópont felhasználó hibakereső változók *}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," felhasználó hibakereső változók: ', new Array (closedGif, openGif)) \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​$ {számláló}) \ n");
_smarty_console.document.write ("var = szülő node $ {számláló} \ n");
{$ Counter + +}

{* Gyermek csomópontok létrehozása a felhasználó hibakereső változók *}
{Name = részben loop = $ vars _user_debug}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ($ {számláló} '{} ldelim $ {$ _user_debug_key [vars]}} {rdelim", pageIcon,' {$ _user_debug [vars] | @ debug_print_var: 0:1000 | Menekülés: javascript | Menekülés: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}
{} Sectionelse
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," nincs belépési Debug információ rendelt ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}
{/ Rész}

{* Csomópont létrehozása sablon változók *}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," célhoz kötött sablon változók: ', new Array (closedGif, openGif)) \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​$ {számláló}) \ n");
_smarty_console.document.write ("var = szülő node $ {számláló} \ n");
{$ Counter + +}

{* Gyermek csomópontok létrehozása sablon változók *}
{Name = részben loop = $ vars _debug_keys}
{If $ _debug_keys [vars]! = '_user_debug' && $ _debug_keys [Vars]! = '_user_debug_key "}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ($ {számláló} '{} ldelim $ {$ _debug_keys [vars]}} {rdelim", pageIcon,' {$ _debug_vals [vars] | @ debug_print_var: 0:1000 | Menekülés: javascript | Menekülés: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}
{/ If}
{} Sectionelse
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," Nem sablon változók rendelve ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}
{/ Rész}

{* Új csomópont Smarty config file változók *}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," célhoz kötött változó konfigurációs fájl (sablon külső kör): ', new Array (closedGif, openGif)) \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​$ {számláló}) \ n");
_smarty_console.document.write ("var = szülő node $ {számláló} \ n");
{$ Counter + +}

{* Új gyermek csomópontok Smarty config file változók *}
{Name = részben config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var node} {$ counter = new TreeNode ($ {számláló} '{} ldelim $ {$ _debug_config_keys [config_vars]}} {rdelim", pageIcon,' {$ _debug_config_vals [config_vars] | @ debug_print_var: 0:1000 | Menekülés: javascript | Menekülés: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}
{} Sectionelse
_smarty_console.document.write ("var node} {$ counter = new TreeNode ({} $ counter," No config változó rendelt ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (node ​​$ {számláló}) \ n");
{$ Counter + +}
{/ Rész}

_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 Debug Console felhasználói & <\ / h3>");
_smarty_console.document.write ("<h4> Kattints a változókat a fán, hogy azok tartalma megjelenik a jobb oldali 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>

Címkék: ,
írt útmutatók , Programozás Owen

Kövesse hozzászólások keresztül RSS | Leave a comment | Trackback URL

Hagyjuk meg véleményét

 
© 2008 - 2012 - Minden jog fenntartva - Ideamesh, Inc. 22 lekéréssel. 0,369 másodperc alatt.