在ecshop中新增頁面,並且實現後臺管理
後臺一共需要修改下面的四個檔案
C:/Program Files/ShopEx/shop/docroot/ecshop/admin/template.php
C:/Program Files/ShopEx/shop/docroot/ecshop/admin/includes/lib_template.php
C:/Program Files/ShopEx/shop/docroot/ecshop/languages/zh_cn/admin/template.php
C:/Program Files/ShopEx/shop/docroot/ecshop/themes/default/libs.xml
1、 首先做模板檔案 help.dwt
見下面的 7 和 8 的檔案內容
2 、修改 C:/Program Files/ShopEx/shop/docroot/ecshop/languages/zh_cn /admin/template.php
追加如下內容
$_LANG['template_files']['help'] = ' 使用者定義幫助 ';
3 、後臺就可以顯示出使用者定義的模板檔案了
4 、修改下面一個檔案的 bug
C:/Program Files/ShopEx/shop/docroot/ecshop/admin/includes/lib_template.php
將 while ($vals[++$i]['tag'] != 'FILE' || !isset($vals[$i]['attributes']))
修改成
$i++;
while ($vals[$i]['tag'] != 'FILE' || !isset($vals[$i]['attributes'])) // 讀出可編輯區庫檔名稱,放到一個數組中
{
……
$i++;
}
5 、【每個模板允許設定的庫專案】做成
C:/Program Files/ShopEx/shop/docroot/ecshop/admin/includes/lib_template.php
在 $page_libs = array(…… 中加入下面程式碼
'help' => array(
'/library/ur_here.lbi' => 0,
'/library/search_form.lbi' => 0,
'/library/member.lbi' => 0,
'/library/new_articles.lbi' => 0,
'/library/category_tree.lbi' => 0,
'/library/top10.lbi' => 0,
'/library/invoice_query.lbi' => 0,
'/library/recommend_best.lbi' => 3,
'/library/recommend_new.lbi' => 3,
'/library/recommend_hot.lbi' => 3,
'/library/recommend_promotion.lbi' => 4,
'/library/group_buy.lbi' => 3,
'/library/auction.lbi' => 3,
'/library/brands.lbi' => 3,
'/library/promotion_info.lbi' => 0,
'/library/cart.lbi' => 0,
'/library/order_query.lbi' => 0,
'/library/email_list.lbi' => 0,
'/library/vote_list.lbi' => 0
),
6 、編輯可否設定
C:/Program Files/ShopEx/shop/docroot/ecshop/themes/default/libs.xml
加入下面程式碼,這些區域就變成可指定的了,以外的部分就不能被設定。如果不在這個檔案中加入任何資訊,所有的專案都是可編輯的
<file name="help.dwt">
<region name=" 左邊區域 ">
<lib>cart</lib>
<lib>category_tree</lib>
<lib>top10</lib>
<lib>promotion_info</lib>
<lib>order_query</lib>
<lib>invoice_query</lib>
<lib>vote_list</lib>
<lib>email_list</lib>
</region>
<region name=" 站內快訊上廣告位(寬: 210px ) "/>
<region name=" 右邊主區域 ">
<lib>recommend_best</lib>
<lib>recommend_new</lib>
<lib>recommend_hot</lib>
<lib>auction</lib>
<lib>group_buy</lib>
</region>
</file>
7 、模板檔案 help.dwt
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>{$page_title}</title>
<!-- TemplateEndEditable --><!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<meta name="Keywords" content="{$keywords}" />
<meta name="Description" content="{$description}" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" href="animated_favicon.gif" type="image/gif" />
<link href="{$ecs_css_path}" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- #BeginLibraryItem "/library/page_header.lbi" --><!-- #EndLibraryItem -->
<div class="AreaR">
<!-- 焦點圖和站內快訊 START-->
<div class="box clearfix">
<div class="box_1 clearfix">
<div class="f_l" id="focus">
<!-- #BeginLibraryItem "/library/index_ad.lbi" --><!-- #EndLibraryItem -->
</div>
<!--news-->
<div id="mallNews" class="f_r">
<div class="NewsTit"></div>
<div class="NewsList tc">
<!-- TemplateBeginEditable name=" 站內快訊上廣告位 " -->
<!-- #BeginLibraryItem "/library/cat_goods.lbi" --><!-- #EndLibraryItem -->
<!-- TemplateEndEditable -->
<!-- #BeginLibraryItem "/library/new_articles.lbi" --><!-- #EndLibraryItem -->
</div>
</div>
<!--news end-->
</div>
</div>
<!-- #BeginLibraryItem "/library/page_footer.lbi" --><!-- #EndLibraryItem -->
</body>
</html>
紅色背景部分是可編輯區域,如下圖
8 、 help.dwt
<?php
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
assign_template('c', array($cat_id));
$position= assign_ur_here(0, 'asdfasdfaadsfasd');
$smarty->assign('ur_here', $position['ur_here']); // 當前位置
$smarty->display('help.dwt');
?>
9 、最終效果