Února
13
2006

Smarty Jak se: Javascript ladění šablony

UPDATE: Balíček ke stažení je k dispozici zde: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Zde je upravený kód, pracovní a je připravena jít ..

Zde je odkaz, kde si můžete stáhnout nanotree javascript ...
http://nanotree.sourceforge.net/~~V

Vyměňte své proměnné {$ Site.framework_pub} vhodně tak, aby javascript a obrázky mohou být načteny správně.

Také si všimněte, přidal jsem do sekce zvládnout uživatelsky definované ladění vars ... Můj ladění struktura se nazývá "_user_debug" a "_user_debug_key"

Pro více informací o tom, jak provádění tohoto Podívejte se na tomto tématu:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

V opačném případě, pokud nejste zájem, je bezpečné odstranění, že část z šablony. Můžete také odstranit {if} prohlášení jsem zvyklý na obal šablony var bod.

Další věc, kterou budete chtít hrát, je, kolik znaků je na výstupu hodnota pro ladění. Podívejte se na to a upravit druhé číslo změnit maximální chars výstup: @ debug_print_var: 0:1000

PS Může někdo zjistit, proč jsem stále prostor nad <h3> v pravém poli?

Doufám, že to pomáhá, vím, že se mi to líbí Úsměv

PS Chcete-li získat všechny javascript správně fungovat stačí upravit řádek "var mynanopath =" a ujistěte se, že poukazuje na vaší veřejné nanopath adresáře. Můžete se nanotree balíček od http://sourceforge.net/projects/nanotree/

Zde je aktualizovaný kód

Kód:
{*
Smarty Vlastní DHTML ladění šablony
@ Author Hielke Hoeve
@ Author Owen Cole se <owenc na ideamesh dot com>
@ Od 02/13/2006 Smarty 2.6.12
@ Balíček Smarty
@ Souboru debug.tpl
*}

{} Assign_debug_info

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

if (self.name == ") {} ldelim
var title = 'konzole';
{} Rdelim
else {} ldelim
var title = 'Console_' + self.name;
{} Rdelim
_smarty_console = window.open ("", title.value, "width = 800, height = 600, velikost, posuvníky = 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 šířka: 100%;} {rdelim \ n");
_smarty_console.document.write ("# debugtreetable td {} ldelim hranice: tenká pevná černá; {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 ("* potřebné k inicializaci stromu \ n".);
_smarty_console.document.write ("* A volat showTree odst. ImagePath). skutečně ukázat strom \ n");
_smarty_console.document.write ("* Nebo to může být provedeno ve skriptu bloku ve spodní části stránky. \ n");
_smarty_console.document.write ("* I když je tato metoda je o něco čistší. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("function init () {ldelim} \ n");
_smarty_console.document.write ("kontejner = 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 ("* Volána, když uživatel klikne na uzel \ n".);
_smarty_console.document.write ("* @ param TreeNode objekt TreeNode, které byly kliknutí. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("Funkce standardClick (TreeNode) {ldelim} \ n");
_smarty_console.document.write ("var MůjText = 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 ("Funkce nodeEdited (TreeNode) {ldelim} \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("var closedGif = '" + + mynanopath "snímky \ / folder_closed.gif" \ n ");
_smarty_console.document.write ("var openGif = '" + + mynanopath "snímky \ / folder_open.gif" \ n ");
_smarty_console.document.write ("var pageIcon = '" + + mynanopath "snímky \ / page16 × 16.gif" \ n ");
_smarty_console.document.write ("var userIcon = '" + + mynanopath "snímky \ / user_16 × 16.gif" \ n ");
_smarty_console.document.write ("var HelpIcon = '" + + mynanopath "snímky \ / help_16 × 16.gif" \ n ");

{* Vytvoření základního uzlu *}
{Přiřazení var = counter value = 0}
_smarty_console.document.write ("rootNode = new TreeNode ($ {čítač}," Smarty Debug ", HelpIcon:" To je Debug strom Nahrazuje klasickou verzi Smarty Debug konzole. ') \ n ");
{$ Counter + +}

{* Vytvořit uzel obsahuje šablony *}
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ($ {čítač}," včetně Šablony a konfigurační soubory v zatížení čas ve vteřinách): "pageIcon, '");
_smarty_console.document.write ("<table width=\"100%\">");
{Název oddílu = šablony loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% je even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {název oddílu = odrážky loop = $ _debug_tpls [šablony]. hloubka} &&& {/ sekce} <font color = {if $ _debug_tpls [šablony]. typu eq "šablony"} {if $ hnědá _debug_tpls [šablony]. Typ eq isset ($ _debug_tpls [šablony] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [šablony] exec_time | string_format:. "% f 0.5"}) {if% templates.index% eq 0} (celkem) {/ if} <\ \ / i> <\ \ / font> {/ if} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{} Sectionelse
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> žádné šablony zahrnuty <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Sekce}
_smarty_console.document.write ("<\ \ / table>");
_smarty_console.document.write ("") \ n ");

_smarty_console.document.write ("rootNode.addChild (uzel {$ counter}) \ n");
{$ Counter + +}

{* Vytvořit uzel pro ladění uživatelské proměnné *}
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ({$ counter} platí, že" ladění uživatelské proměnné: "new Array (closedGif, openGif)) \ n");
_smarty_console.document.write ("rootNode.addChild (uzel {$ counter}) \ n");
_smarty_console.document.write ("var rodič uzel = {$ counter} \ n");
{$ Counter + +}

{* Vytvořit podřízené uzly pro ladění uživatelské proměnné *}
{Název oddílu = Vars loop = $ _user_debug}
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ({$ counter} '{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 (uzel {$ counter}) \ n");
{$ Counter + +}
{} Sectionelse
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ({$ counter}" Ne uživatele Debug Information přidělen ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (uzel {$ counter}) \ n");
{$ Counter + +}
{/ Sekce}

{* Vytvořit uzel pro * šablony proměnné}
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ($ {čítač}," přiřazená šablona proměnné: "new Array (closedGif, openGif)) \ n");
_smarty_console.document.write ("rootNode.addChild (uzel {$ counter}) \ n");
_smarty_console.document.write ("var rodič uzel = {$ counter} \ n");
{$ Counter + +}

{* Vytvořit podřízené uzly pro šablony proměnných *}
{Název oddílu = Vars loop = $ _debug_keys}
{If $ _debug_keys [Vars]! = && Už _user_debug '$ _debug_keys [Vars]! =' _user_debug_key '}
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ({$ counter} '{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 (uzel {$ counter}) \ n");
{$ Counter + +}
{/ If}
{} Sectionelse
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ($ {čítač}," žádná šablona proměnné přiřazené ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (uzel {$ counter}) \ n");
{$ Counter + +}
{/ Sekce}

{* Vytvořit uzel pro Smarty proměnných konfiguračních souborů *}
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ($ {čítač}," konfiguračním souboru přiřazen proměnné (vnější šablona rozsah): "new Array (closedGif, openGif)) \ n");
_smarty_console.document.write ("rootNode.addChild (uzel {$ counter}) \ n");
_smarty_console.document.write ("var rodič uzel = {$ counter} \ n");
{$ Counter + +}

{* Vytvořit podřízené uzly pro Smarty proměnných konfiguračních souborů *}
{Název oddílu = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("uzel var {$ 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 (uzel {$ counter}) \ n");
{$ Counter + +}
{} Sectionelse
_smarty_console.document.write ("uzel var {$ counter} = new TreeNode ($ {čítač}," žádné konfigurační proměnné přiřazené ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (uzel {$ counter}) \ n");
{$ Counter + +}
{/ Sekce}

_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 & Uživatel Debug konzole <\ / h3>");
_smarty_console.document.write ("<h4> Klikněte na proměnných ve stromu mít jejich obsah zobrazí v pravém postranním panelu <\ / 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>

Tagy: ,
posláno do vodítka , programování od Owen

Sledovat komentáře přes RSS feed | zanechat komentář | Trackback URL

Zanechte svůj komentář

© 2008 - 2012 - Všechna práva vyhrazena - Ideamesh, Inc 22 dotazů. 0.268 sekund.