Februari
13
2006

Smarty Cara: Template Javascript Debug

UPDATE: Sebuah paket download tersedia di sini: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Berikut adalah kode dimodifikasi, bekerja dan siap untuk pergi ..

Berikut adalah link di mana Anda dapat men-download javascript nanotree ...
http://nanotree.sourceforge.net/~~V

Ganti variabel saya {$ Site.framework_pub} tepat sehingga javascript dan gambar dapat dimasukkan dengan benar.

Juga perlu diketahui, saya telah menambahkan di bagian untuk menangani vars debug ditetapkan pengguna ... struktur debug saya bernama '_user_debug' dan '_user_debug_key'

Untuk info lebih lanjut tentang bagaimana melaksanakan ini melihat thread ini:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Sebaliknya jika anda tidak tertarik, adalah aman untuk menghapus bagian tersebut dari template. Anda juga bisa menghapus pernyataan {if} Aku digunakan untuk membungkus bagian var template.

Hal lain yang mungkin ingin bermain dengan adalah berapa banyak karakter adalah output sebagai nilai untuk debug. Carilah ini dan mengubah angka kedua untuk mengubah output chars max: @ debug_print_var: 0:1000

PS Ada yang bisa mencari tahu mengapa saya mendapatkan ruang di atas <h3> dalam sel kanan?

Semoga ini bisa membantu, saya tahu saya menyukainya Tersenyum

PS Untuk mendapatkan semua javascript bekerja dengan benar Anda hanya perlu memodifikasi baris "var mynanopath =" dan pastikan itu menunjuk ke direktori nanopath umum Anda. Anda dapat turun paket nanotree dari http://sourceforge.net/projects/nanotree/

Berikut adalah kode diperbarui

Kode:
{*
Smarty Kustom DHTML Debug Template
@ Penulis Hielke Hoeve
@ Penulis Owen Cole <owenc di ideamesh dot com>
@ Sejak 2006/02/13 Smarty 2.6.12
@ Paket 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, 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} 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: hitam solid tipis, {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 ("* Dibutuhkan untuk menginisialisasi pohon \ n.");
_smarty_console.document.write ("* Dan untuk memanggil showTree (ImagePath);. untuk benar-benar menunjukkan pohon \ n");
_smarty_console.document.write ("* Atau hal ini dapat dilakukan dalam rangkaian script di bawah halaman \ n.");
_smarty_console.document.write ("* Meskipun metode ini agak bersih \ n.");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("fungsi init () {ldelim} \ n");
_smarty_console.document.write ("wadah = 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 ("* Disebut bila pengguna mengklik pada node \ n.");
_smarty_console.document.write ("* @ param TreeNode obyek TreeNode yang telah diklik \ n.");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("fungsi 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 ("fungsi 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 \ / page16 × 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");

{* Membuat * dasar simpul}
{Assign var = counter value = 0}
_smarty_console.document.write ("rootNode = new TreeNode ({} $ counter," Smarty Debug ', helpIcon,' Ini adalah Pohon Debug Ia menggantikan versi klasik Console Debug Smarty. '); \ n ");
{$ Counter + +}

{* Membuat simpul untuk template mencakup *}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," termasuk template & file config (beban waktu dalam detik): ', pageIcon,' ");
_smarty_console.document.write ("<table width=\"100%\">");
{Section name = template loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% adalah even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {nama bagian = indent loop = $ _debug_tpls [template] kedalaman}. &&& {/ section} <warna font = {if $ _debug_tpls [template] jenis eq. "template"} {elseif $ coklat _debug_tpls [template] jenis eq. isset ($ _debug_tpls [template] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [template] 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> tidak termasuk template <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Section}
_smarty_console.document.write ("<\ \ / table>");
_smarty_console.document.write ("'); \ n");

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

{* Buat node untuk variabel debug pengguna *}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," variabel pengguna debug: ', new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ counter}); \ n");
_smarty_console.document.write ("var induk = simpul {$ counter}; \ n");
{$ Counter + +}

{* Membuat node anak untuk variabel debug pengguna *}
{Section name = vars loop = $ _user_debug}
_smarty_console.document.write ("var simpul {$ 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 (node ​​{$ counter}); \ n");
{$ Counter + +}
{Sectionelse}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," Tidak Debug Informasi Pengguna ditugaskan ', HelpIcon); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ counter}); \ n");
{$ Counter + +}
{/ Section}

{* Buat node untuk variabel template *}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," variabel template yang ditempati: ', new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ counter}); \ n");
_smarty_console.document.write ("var induk = simpul {$ counter}; \ n");
{$ Counter + +}

{* Membuat node anak untuk variabel template *}
{Section name = vars loop = $ _debug_keys}
{If $ _debug_keys [vars] = && '_user_debug' $ _debug_keys [vars] = '_user_debug_key'}
_smarty_console.document.write ("var simpul {$ 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 (node ​​{$ counter}); \ n");
{$ Counter + +}
{/ If}
{Sectionelse}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," variabel template Tidak ditugaskan ', HelpIcon); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ counter}); \ n");
{$ Counter + +}
{/ Section}

{* Buat node untuk variabel file config smarty *}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," variabel yang ditempati file konfigurasi (lingkup template yang luar): ', baru Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ counter}); \ n");
_smarty_console.document.write ("var induk = simpul {$ counter}; \ n");
{$ Counter + +}

{* Membuat node anak untuk variabel file konfigurasi smarty *}
{Section name = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var simpul {$ 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 (node ​​{$ counter}); \ n");
{$ Counter + +}
{Sectionelse}
_smarty_console.document.write ("var simpul {$ counter} = new TreeNode ({} $ counter," Tidak ada variabel config yang ditugaskan ', HelpIcon); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ counter}); \ n");
{$ Counter + +}
{/ 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 & Konsol Pengguna Debug <\ / h3>");
_smarty_console.document.write ("<h4> Klik pada variabel di pohon untuk memiliki isinya ditampilkan di panel sisi kanan <\ / h4>.");
_smarty_console.document.write ("<table border='0' id='debugtreetable'> <tr>");
_smarty_console.document.write ("valign='top' <td 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: ,
diposting di Panduan , Pemrograman oleh Owen

Ikuti komentar melalui RSS Feed | Leave a comment | Trackback URL

Tinggalkan Komentar Anda

 
© 2008 - 2012 - All Rights Reserved - Ideamesh, Inc 22 pertanyaan. 0,424 detik.