Pebrero
13
2006

Smarty Paano sa: Javascript Debug Template

Update: Ang isang pag-download pakete ay makukuha dito: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Narito ang binagong code, nagtatrabaho at handa na upang pumunta ...

Narito ang link kung saan maaari mong i-download ang nanotree javascript ...
http://nanotree.sourceforge.net/~~V

Palitan ang aking variable {$ Site.framework_pub} naaangkop sa gayon na ang javascript at mga imahe ay maaaring mai-load nang tama.

Ang din pakitandaan, ako idinagdag sa isang seksyon upang mahawakan ang mga tinukoy ng gumagamit vars debug ... Aking debug istraktura ay pinangalanan sa '_user_debug' at '_user_debug_key'

Para sa karagdagang impormasyon sa kung paano ipatupad ang hitsura na ito sa thread na ito:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31,241

Kung hindi man kung hindi ikaw ay interesado, ito ay ligtas sa alisin ang seksyon na iyon mula sa template. Maaari mo ring tanggalin ang {kung} pahayag na ginamit ko upang Pakibalot seksyon ng template ng var.

Ang isa pang bagay na maaari mong upang i-play ay kung gaano karaming mga character ay output bilang ang halaga para sa debug. Maghanap para sa at baguhin ang ikalawang numero upang baguhin ang max output karakter: @ debug_print_var: 0:1000

PS Maaari kahit sino malaman kung bakit ako nakakakuha ng isang puwang itaas ng <h3> sa kanang cell?

Sana ito ay makakatulong, alam ko gusto ko ito Ngiti

PS Upang makakuha ng lahat ng javascript gumagana nang tama kailangan mo lamang baguhin ang linya na "var mynanopath =" at siguraduhin na ang mga puntos na ito sa iyong pampublikong nanopath direktoryo. Maaari mong pababa ang nanotree na pakete mula sa http://sourceforge.net/projects/nanotree/

Ito ay na-update na code

Code:
{*
Debug Template ng ng Smarty Custom DHTML
@ Hielke Hoeve may-akda
@ Akda Owen ng Cole <owenc sa ideamesh tuldok com>
@ Dahil 2006/02/13 Smarty 2.6.12
@ Pakete Smarty
@ Filename debug.tpl
*}

{Assign_debug_info}

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

kung (self.name == ") {ldelim}
var pamagat = 'Console';
{Rdelim}
iba {ldelim}
var pamagat = 'Console_' + self.name;
{Rdelim}
_smarty_console = window.open ("", title.value, "lapad = 800, taas = 600, resizable, 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} na padding: 5px 5px 5px 5px; margin: 0px 0px 0px 0px; background-kulay: # cccccc; {rdelim} \ n");
_smarty_console.document.write ("# debugtreetable na {ldelim} lapad: 100%; {rdelim} \ n");
_smarty_console.document.write ("# debugtreetable td {ldelim} na hangganan: manipis na solid black; {rdelim} \ n");
_smarty_console.document.write ("ng # debugtreetextdiv div {ldelim} padding-kaliwa: 10px; {rdelim} \ n");
_smarty_console.document.write ("<\ / na istilo> \ 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 ("* Kinakailangan ang pagsisimula ng tree \ n");
_smarty_console.document.write ("* At sa tumawag showTree (imagePath); sa aktwal na ipakita ang tree \ n");
_smarty_console.document.write ("* Bilang kahalili ito ay maaaring gawin sa isang bloke ng script sa ibaba ng pahina \ n");
_smarty_console.document.write ("* Kahit na ang paraan na ito ay medyo mas malinis \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("ang function init () {ldelim} \ n");
_smarty_console.document.write ("lalagyan = 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 ("* Tinatawag na kapag ang isang gumagamit ay nag-click sa isang node \ n");
_smarty_console.document.write ("* @ param treeNode ang TreeNode bagay na na-click \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("function na standardClick na (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 ("ang pagpapaandar nodeEdited (treeNode) {ldelim} \ n");
_smarty_console.document.write ("{rdelim} \ n");

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

{* Lumikha ng base node *}
{Magtalaga var = counter halaga = 0}
_smarty_console.document.write ("rootNode = bagong TreeNode ({$ kontra}, Smarty Debug ', helpIcon, ito ay ang Debug Tree pumapalit sa classical na bersyon ng Smarty Debug Console.'); \ n");
{$ Counter + +}

{* Gumawa ng node para sa template ay may kasamang *}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, 'kasama ang mga template at config file (oras ng pagkarga sa ilang mga segundo):', pageIcon, '");
_smarty_console.document.write ("<table width=\"100%\">");
{Pangalan ng seksyon = template ng loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% ay even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {pangalan ng seksyon = indent loop = $ _debug_tpls [template]. depth} &&& {/ section} <font kulay = {kung $ _debug_tpls ay [template]. uri eq "template"} kayumanggi {elseif $ _debug_tpls [template]. uri eq isset ($ _debug_tpls [template] exec_time.)} <font size=-1> <i> ({sa $ _debug_tpls [template] exec_time | string_format: "% ang .5 f"}) {kung templates.index%% eq 0} (kabuuan) {/ kung} <\ \ / i> <\ \ / font> {/ kung} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{Sectionelse}
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> walang mga template kasama <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Seksyon}
_smarty_console.document.write ("<\ \ / talahanayan>");
_smarty_console.document.write ("'); \ n");

_smarty_console.document.write ("rootNode.addChild (node ​​{$ kontra}); \ n");
{$ Counter + +}

{* Lumikha ng node para sa mga variable ng gumagamit debug *}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, 'debug variable ng gumagamit:', bagong array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ kontra}); \ n");
_smarty_console.document.write ("var magulang = node {$ kontra}; \ n");
{$ Counter + +}

{* Gumawa ng mga mga nodes bata para sa mga variable ng gumagamit debug *}
{Pangalan ng seksyon = vars loop = $ _user_debug}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode ({$ kontra}, 'na {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 (node ​​{$ kontra}); \ n");
{$ Counter + +}
{Sectionelse}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, Walang Impormasyon ng User Debug na nakatalaga ', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ kontra}); \ n");
{$ Counter + +}
{/ Seksyon}

{* Gumawa ng node para sa mga variable ng template *}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, 'bibigyan ng variable ng template:', bagong array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ kontra}); \ n");
_smarty_console.document.write ("var magulang = node {$ kontra}; \ n");
{$ Counter + +}

{* Lumikha mga nodes bata para sa mga variable ng template *}
{Pangalan ng seksyon ang = vars loop = $ _debug_keys}
{Kung $ _debug_keys [vars]! = '_user_debug' && $ _debug_keys [Vars]! = '_user_debug_key'}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode ({$ kontra}, 'na {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 (node ​​{$ kontra}); \ n");
{$ Counter + +}
{/ Kung}
{Sectionelse}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, 'Walang template variable na nakatalaga', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ kontra}); \ n");
{$ Counter + +}
{/ Seksyon}

{* Gumawa ng node para sa mga smarty config file variable *}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, 'na nakatalaga config file variable (panlabas na saklaw ng template):', bagong array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ kontra}); \ n");
_smarty_console.document.write ("var magulang = node {$ kontra}; \ n");
{$ Counter + +}

{* Gumawa ng mga nodes ng bata para sa mga smarty config file variable *}
{Pangalan ng seksyon ang = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode ({$ kontra}, 'na {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 (node ​​{$ kontra}); \ n");
{$ Counter + +}
{Sectionelse}
_smarty_console.document.write ("var node {$ kontra} = bagong TreeNode sa ({$ kontra}, 'mga Walang config variable na itinalaga', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ kontra}); \ n");
{$ Counter + +}
{/ Seksyon}

_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 & Gumagamit Debug Console <\ / h3>");
_smarty_console.document.write (sa "<h4>-click sa mga variable sa tree upang ang kanilang mga nilalaman na ipinapakita sa kanang bahagi ng panel <\ / 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> <\ / talahanayan>");
_smarty_console.document.write ("<\ / body> <\ / html>");
_smarty_console.document.close ();
</ Script>

tags: ,
nai-post sa Guides , Programming sa pamamagitan ng Owen

Sundin ang mga puna sa pamamagitan ng RSS Feed | Mag-iwan ng puna | Trackback URL

Iwanan ang iyong komento

 
© 2008 - 2012 - All Rights Reserved - Ideamesh, Inc. 22 query. 0.268 segundo.