Tháng Hai
13
2006

Smarty Làm thế nào để gỡ lỗi Template: Javascript

UPDATE: Một gói phần mềm tải về là có sẵn ở đây: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Dưới đây là mã sửa đổi, làm việc và sẵn sàng để đi ..

Dưới đây là liên kết nơi bạn có thể tải về các javascript nanotree ...
http://nanotree.sourceforge.net/~~V

Thay thế biến của tôi {$ Site.framework_pub. Thích hợp để mà javascript và hình ảnh có thể được nạp một cách chính xác.

Cũng xin lưu ý, tôi đã thêm vào trong phần xử lý vars gỡ lỗi người dùng định nghĩa cấu trúc gỡ lỗi của tôi được đặt tên là '_user_debug' và '_user_debug_key'

Để biết thêm về làm thế nào để thực hiện điều này xem chủ đề này:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Nếu không, nếu bạn không quan tâm, nó là an toàn để loại bỏ phần từ mẫu. Bạn cũng có thể loại bỏ các tuyên bố if} tôi được sử dụng để bọc các phần var mẫu.

Một điều bạn có thể muốn chơi với bao nhiêu nhân vật đầu ra như giá trị để gỡ lỗi. Hãy tìm và sửa đổi số thứ hai để thay đổi sản lượng ký tự tối đa: @ debug_print_var: 0:1000

PS Bất cứ ai có thể tìm ra lý do tại sao tôi nhận được một không gian trên <h3> trong ô bên phải?

Hy vọng điều này sẽ giúp, tôi biết tôi thích nó Nụ cười

PS Để có được tất cả các javascript làm việc một cách chính xác bạn chỉ cần sửa đổi dòng "var mynanopath =" và chắc chắn rằng nó chỉ thư mục nanopath công cộng của bạn. Bạn có thể giảm các gói nanotree từ http://sourceforge.net/projects/nanotree/

Đây là mã cập nhật

Mã số:
{*
Smarty Tuỳ chỉnh DHTML gỡ lỗi Template
@ Tác giả Hielke Hoeve
@ Tác giả Owen Cole <owenc tại ideamesh dot com>
@ Kể từ 2006/02/13 Smarty 2.6.12
Lúc gói Smarty
Lúc tên tập tin debug.tpl
*}

{Assign_debug_info}

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

if (self.name == ") {ldelim}
var title = 'điều khiển';
Rdelim}
khác {ldelim}
var title = 'Console_ + self.name;
Rdelim}
_smarty_console = window.open ("", title.value, "width = 800, chiều cao = 600, thay đổi kích thước, scrollbars = yes");
_smarty_console.document.write ("<html> <head> <title> Smarty gỡ lỗi 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., biên giới: mỏng màu đen; {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 (* cần thiết để khởi tạo các cây \ n ");
_smarty_console.document.write ("* Và gọi showTree (ImagePath); để thực sự hiển thị cây \ n");
_smarty_console.document.write ("* Ngoài ra, điều này có thể được thực hiện trong một khối kịch bản ở dưới cùng của trang \ n");
_smarty_console.document.write (* Mặc dù phương pháp này là hơi sạch hơn \ n ");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("chức năng 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 ("* Được gọi là khi người dùng nhấp chuột vào một nút \ n");
_smarty_console.document.write ("* @ param TreeNode đối tượng TreeNode được click \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("chức năng 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 ("chức năng 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 ");

{* Tạo nút cơ sở *}
{Gán var = truy cập giá trị = 0}
_smarty_console.document.write (rootNode = new TreeNode ({$ truy cập}, Smarty Debug ', helpIcon,' Đây là cây Debug thay thế phiên bản cổ điển của Console gỡ lỗi Smarty. '); \ n ");
{$ Counter + +}

{* Tạo nút cho mẫu bao gồm *}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập} ', bao gồm các mẫu và các tập tin cấu hình (thời gian tải trong vài giây):', pageIcon,");
_smarty_console.document.write ("<table width=\"100%\">");
{Mục name = mẫu loop = $ _debug_tpls}
_smarty_console.document.write (: <tr bgcolor={if %templates.index% là even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {mục tên = thụt loop = $ _debug_tpls [mẫu] chiều sâu}. &&& {/ section} <font color = {$ _debug_tpls [mẫu] loại eq "mẫu"} nâu {elseif $ _debug_tpls [mẫu] loại eq. isset ($ _debug_tpls [mẫu] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [mẫu] exec_time | string_format: "% 0,5 f"}) {nếu%% eq templates.index 0} (tổng số) {/ if} <\ \ / i> <\ \ / font> {/} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
Sectionelse}
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> không có các mẫu bao gồm <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Section}
_smarty_console.document.write ("<\ \ / table>");
_smarty_console.document.write ("'); \ n");

_smarty_console.document.write ("rootNode.addChild (nút {$ truy cập}), \ n");
{$ Counter + +}

{* Tạo nút cho các biến gỡ lỗi người sử dụng *}
_smarty_console.document.write (var nút {$ truy cập} = new TreeNode ({$ truy cập}, người sử dụng biến debug: ', new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (nút {$ truy cập}), \ n");
_smarty_console.document.write ("var cha mẹ = nút {$ truy cập} \ n");
{$ Counter + +}

{* Tạo các nút con cho các biến gỡ lỗi người sử dụng.
{Mục name = vars loop = $ _user_debug}
_smarty_console.document.write ("var nút {$ truy cập = new TreeNode ({$ truy cập}, {ldelim} $ {$ _user_debug_key [VAR]} {rdelim}, pageIcon, '{$ _user_debug [VAR] | @ debug_print_var: 0:1000 | thoát: javascript | thoát: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (nút {$ truy cập}), \ n");
{$ Counter + +}
Sectionelse}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập}, 'Không có gỡ lỗi Thông tin người sử dụng giao', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (nút {$ truy cập}), \ n");
{$ Counter + +}
{/ Section}

{* Tạo nút cho các biến mẫu *}
_smarty_console.document.write (var nút {$ truy cập} = new TreeNode ({$ truy cập}, 'biến mẫu được giao:', new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (nút {$ truy cập}), \ n");
_smarty_console.document.write ("var cha mẹ = nút {$ truy cập} \ n");
{$ Counter + +}

{* Tạo các nút con cho các biến mẫu *}
{Mục name = vars loop = $ _debug_keys}
{Nếu $ _debug_keys [VAR] = '_user_debug' && $ _debug_keys [VAR] = '_user_debug_key'}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập}, {ldelim} $ {_debug_keys [VAR]} {rdelim}, pageIcon, '{$ _debug_vals [VAR] | @ debug_print_var: 0:1000 | thoát: javascript | thoát: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (nút {$ truy cập}), \ n");
{$ Counter + +}
{/ If}
Sectionelse}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập}, 'Không có biến mẫu giao', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (nút {$ truy cập}), \ n");
{$ Counter + +}
{/ Section}

{* Tạo nút cho các biến tập tin cấu hình smarty *}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập}, được giao file cấu hình biến (mẫu phạm vi bên ngoài), new Array (closedGif, openGif)); \ n");
_smarty_console.document.write ("rootNode.addChild (nút {$ truy cập}), \ n");
_smarty_console.document.write ("var cha mẹ = nút {$ truy cập} \ n");
{$ Counter + +}

{* Tạo các nút con cho smarty biến tập tin cấu hình *}
{Tên phần nhất = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập}, {ldelim} $ {_debug_config_keys [config_vars]} {rdelim}, pageIcon, '{$ _debug_config_vals [config_vars] | @ debug_print_var: 0:1000 | thoát: javascript | thoát: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (nút {$ truy cập}), \ n");
{$ Counter + +}
Sectionelse}
_smarty_console.document.write ("var nút {$ truy cập} = new TreeNode ({$ truy cập}, 'Không có cấu hình biến giao', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (nút {$ truy cập}), \ 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 tài điều khiển gỡ lỗi <\ / h3> ");
_smarty_console.document.write ("<h4> Click vào biến trong cây có các nội dung hiển thị trong bảng điều khiển phía bên phải <\ / 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: ,
Hướng dẫn , Lập trình bởi Owen

Thực hiện theo ý kiến thông qua RSS Feed | Để lại một bình luận | Trackback URL

Để lại bình luận của bạn

 
© năm 2008 - năm 2012 - Tất cả các quyền - Ideamesh, Inc. 22 truy vấn. 1,064 giây.