Febreiro
13
2006

Smarty Como: Javascript Template Debug

Update: Un paquete de descarga está dispoñible aquí: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Aquí está o código modificado, traballando e preparado para ir ..

Aquí está a ligazón onde podes descargar o javascript nanotree ...
http://nanotree.sourceforge.net/ ~ ~ V

Substituír miña variable {$ Site.framework_pub} correctamente para que o javascript e as imaxes poden ser cargadas correctamente.

Teña en conta tamén, eu engade nunha sección para xestionar vars depuración definidos polo usuario ... A miña estrutura de depuración chámase '_user_debug' e '_user_debug_key'

Para máis información sobre como aplicar esta ollada neste segmento:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Se non, se non está interesado, é seguro para eliminar esa sección do modelo. Tamén pode eliminar a instrución {if} eu usado para embrulhar a sección var modelo.

Outra cousa que pode querer xogar coa forma como moitos personaxes están de saída como o valor de depuración. Olhe a este e modificar o segundo número para cambiar a saída chars max: debug_print_var @: 0:1000

PS Alguén pode descubrir por que eu estou quedando un espazo enriba do <h3> na célula non?

Espero que isto axude, eu sei que me gusta Sorrir

PS Para todo o Javascript funcionando correctamente, só precisa modificar a liña "var mynanopath =" e asegúrese de que apunta ao directorio nanopath público. Podes baixar o paquete de nanotree http://sourceforge.net/projects/nanotree/

Aquí está o código actualizado

Código:
{*
Smarty Template personalizado Debug DHTML
@ Author Hielke Hoeve
@ Author Owen Cole <owenc en ideamesh punto com>
@ Since 2006/02/13 Smarty 2.6.12
@ Paquete Smarty
@ Filename debug.tpl
*}

{} Assign_debug_info

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

if (self.name == ") {} ldelim
var title = 'Consola';
{} Rdelim
else {} ldelim
var title = 'Console_' + self.name;
{} Rdelim
_smarty_console = window.open ("", title.value, "width = 800, altura = 600, resizable, scrollbars = yes");
_smarty_console.document.write ("<html> <head> <title> Debug Smarty Console_" + self.name + "<\ / title> \ n");
_smarty_console.document.write ("<style> \ n");
_smarty_console.document.write ("h3 {recheo ldelim}: 5px 5px 5px 5px; Margin: 0px 0px 0px 0px; background-color: # cccccc;} {rdelim \ n");
_smarty_console.document.write ("# {width debugtreetable ldelim}: 100%;} {rdelim \ n");
_smarty_console.document.write ("# debugtreetable td fronteira {} ldelim: thin negro sólido; {rdelim} \ n");
_smarty_console.document.write ("# debugtreetextdiv span {} 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 ("* Necesario para arrincar a árbore \ n".)
_smarty_console.document.write ("* E para chamar showtree (ImagePath). que realmente mostran a árbore de \ n");
_smarty_console.document.write ("* Alternativamente, esta pode ser feito dun bloque de script, na parte inferior da páxina \ n. ');
_smarty_console.document.write ("* Aínda que este método é un pouco máis limpo. \ 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 ('" + mynanopath + "'); \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("\ / ** \ n");
_smarty_console.document.write ("* Chamado cando un usuario fai clic nun nó de \ n".)
_smarty_console.document.write ("* @ param TreeNode TreeNode o obxecto que foi premendo \ n. ');
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("función StandardClick (TreeNode) {ldelim} \ n");
_smarty_console.document.write ("var mytext = document.getElementById ('debugtreetextdiv'); \ n");
_smarty_console.document.write ("var paran = treeNode.getParam (); \ n");
_smarty_console.document.write ("mytext.innerHTML = paran (==") treeNode.getName ():? <h3> '+ treeNode.getName () +' <\ / h3> <div '+ paran + " <\ / a> '; \ n ");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("función 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 \ / páxina 16 × 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 ");

{* Crear nodo base}
{Asignar var = valor do contador = 0}
_smarty_console.document.write ("rootNode = new TreeNode ({$ contador}, 'Debug Smarty', helpIcon, 'Esta é a Árbore Debug El substitúe a versión clásica da consola de depuración Smarty.'); \ n");
{$ Contador + +}

{* Crear nó para o modelo inclúe *}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'incluídos modelos e ficheiros de configuración (tempo de carga en segundos):', pageIcon '");
_smarty_console.document.write ("<table width=\"100%\">");
{Nome da sección = lazo modelos = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% é even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {section name = lazo guión = $ _debug_tpls [modelos]. profundidade} &&& {/ section} <cor da fonte = {if $ _debug_tpls [modelos]. tipo eq "template"} {elseif $ marrón _debug_tpls [modelos]. tipo eq isset ($ _debug_tpls [modelos] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [modelos] exec_time | string_format:. ".5% f"}) {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> sen modelos incluídos <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Section}
_smarty_console.document.write ("<\ \ / table>");
_smarty_console.document.write (""); \ n ");

_smarty_console.document.write ("rootNode.addChild (nodo {$ contador}): \ n");
{$ Contador + +}

{* Crear nodo para as variables de depuración do usuario *}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'variables de depuración do usuario:", new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (nodo {$ contador}): \ n");
_smarty_console.document.write ("var parent = nodo {$ contador}; \ n");
{$ Contador + +}

{* Crear nós fillos para as variables de depuración do usuario *}
{Nome da sección = loop = $ vars _user_debug}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, '{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 (nodo {$ contador}): \ n");
{$ Contador + +}
{} Sectionelse
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'Non hai información Debug usuario afectadas», HelpIcon) \ n ");
_smarty_console.document.write ("parent.addChild (nodo {$ contador}): \ n");
{$ Contador + +}
{/ Section}

{* Crear nodo * variables modelo}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'variables de plantilla fixadas:' new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (nodo {$ contador}): \ n");
_smarty_console.document.write ("var parent = nodo {$ contador}; \ n");
{$ Contador + +}

{* Crear nós fillo para variables de plantilla *}
{Nome da sección = lazo vars = $ _debug_keys}
{If $ _debug_keys [VARS]! = '_user_debug' && $ _debug_keys [VARS]! = '_user_debug_key'}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, '{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 (nodo {$ contador}): \ n");
{$ Contador + +}
{/ If}
{} Sectionelse
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'Non hai variables de plantilla fixadas", HelpIcon) \ n ");
_smarty_console.document.write ("parent.addChild (nodo {$ contador}): \ n");
{$ Contador + +}
{/ Section}

{* Crear nodo para as variables de arquivos de Smarty *}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'atribúe as variables do ficheiro de configuración (ámbito modelo externo):", new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (nodo {$ contador}): \ n");
_smarty_console.document.write ("var parent = nodo {$ contador}; \ n");
{$ Contador + +}

{* Crear nós fillo para variables de arquivos de Smarty *}
{Nome da sección = lazo config_vars = $ _debug_config_keys}
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, '{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 (nodo {$ contador}): \ n");
{$ Contador + +}
{} Sectionelse
_smarty_console.document.write ("no var {$ contador} = new TreeNode ({$ contador}, 'Non hai variables de configuración asignados", HelpIcon) \ n ");
_smarty_console.document.write ("parent.addChild (nodo {$ contador}): \ n");
{$ Contador + +}
{/ 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 Debug Console & Usuario <\ / h3>");
_smarty_console.document.write ("Click <h4> en variables na árbore para que os seus contidos presentados no panel do lado dereito <\ / h4>.");
_smarty_console.document.write ("<table border='0' id='debugtreetable'> <tr>");
_smarty_console.document.write ("valign =" top "<td style='width: 250px;'> <div id='debugtreediv'> & <\ / a> <\ / 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: ,
publicou en Guide , programación por Owen

Estes son os comentarios a través do RSS Feed | Deixe un comentario | Trackback URL

Deixe o seu comentario

 
© 2008 - 2012 - Todos os dereitos reservados - Ideamesh, Inc 22 procedementos. 1.086 segundos.