2009年9月25日 星期五

Zencart內自己建立側邊欄位Sideboxes

要建立自己的側邊欄位,首先
1.在自己的模組資料夾內建立一個sideboxes的資料夾。
2.一個側邊欄位的建立需要包含連結以下三個檔案











  • modules/sideboxes/template_name/name_of_sidebox.php'
  • languages/english/extra_definitions/template_name/ name_of_sidebox_defines.php '
  • templates/template_name/sideboxes/tpl_name_of_sidebox.php '


將上述的template_name改成自己的模組名稱


如何建立這些連結檔案呢?假設我們要建立一個叫my_sidebox的側邊欄位,那麼在
modules/sideboxes/template_name/my_sidebox.php  應該這樣寫:








<?php
 $show_my_sidebox = true;
 if ($show_my_sidebox == true){
 require($template->get_template_dir('tpl_my_sidebox.php', DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_my_sidebox.php');
 $title = BOX_HEADING_MY_SIDEBOX;
 $left_corner = false;
 $right_corner = false;
 $right_arrow = false;
 require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . 
$column_box_default);
  }
 ?>


3.接著建立定義這個側邊欄位的標題名稱的檔案於includes/languages/english/extra_definitions/packt/my_sidebox_defines.php

<?php
  define('BOX_HEADING_MY_SIDEBOX', 'My Sidebox');
 ?>



4.然後開始建立 includes/templates/packt/sideboxes/tpl_my_sidebox.php這個檔案,如下:







<?php
  $content = "This is my first Sidebox. I have created it in 5 minutes. Although it is not of practical use yet, I 
 hope I can eventually build a good sidebox.";
 ?>


之後在到購物網站的後台管理界面,將側邊欄位開啓,即可看到~








沒有留言: