广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > Ecshop新增单页面模板的方法

二次开发Ecshop二次开发

二次开发Ecshop二次开发

Ecshop新增单页面模板的方法

 【第一】在根目录创建一个php文件,命名为single.php[注:single.php乃我自定义的页面。
<?php
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
if ((DEBUG_MODE &
2) != 2)
{$smarty->caching = true;}
/* 清除缓存
*/
clear_cache_files();
//引用模板
if (!$smarty->is_cached('single.dwt', $cache_id)){
   assign_template();
  //红色区是单页面需要调用到的数据,需要哪一部分就将其引用进来。
$position =
assign_ur_here();
    $smarty->assign('page_title',    
$position['title']);    // 页面标题
    $smarty->assign('ur_here',       
$position['ur_here']);  // 当前位置
    /* meta information */
   $smarty->assign('keywords',    
   htmlspecialchars($_CFG['shop_keywords']));  
$smarty->assign('description', 
   htmlspecialchars($_CFG['shop_desc']));
$smarty->assign('helps',           get_shop_help());       //网店帮助
}
$smarty->display('single.dwt',
$cache_id);
?>

【第二】在模板文件夹里面创建single
.dwt文件[注:single.dwt跟single.php的页面一致,因为其代码里引用了该模板名称。]
添加代码:

<!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=GBK" />
<meta
name="Keywords" content="{$keywords}" />
<meta name="Description"
content="{$description}" />
<!-- TemplateBeginEditable name="doctitle"-->
<title>68ecshop</title>
<!-- TemplateEndEditable-->
<!-- TemplateBeginEditable name="head" -->
<!--TemplateEndEditable -->
<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="wrapper">
    <div id="ur_here">
   <!--#BeginLibraryItem "/library/ur_here.lbi" --><!-- #EndLibraryItem-->
     </div>
把你创建的html里面的html内容复制放在这里
</div>
<!--#BeginLibraryItem "/library/page_footer.lbi" --><!-- #EndLibraryItem-->
</body>
</html>


【第三】单页面必须要有”当前位置“这个文件存在(/library/ur_here.lbi)那么需要修改以下2个文件的代码:
【1】找到includes/lib_main.php文件,修改:
找到代码155行起,
/*初始化“页面标题”和“当前位置” */
/* 积分兑换 */
            elseif
('exchange' == $filename)
            {
                $page_title =
$GLOBALS['_LANG']['exchange'] . '_' . $page_title;
                $args    
  = array('wsid' => '0');
                $ur_here   .= '
<code>></code> <a href="exchange.php">' .
    $GLOBALS['_LANG']['exchange'] . '</a>';          
}
 /* 其他的在这里补充 */
在积分兑换下面新增:
/* 新增单页面 */
          elseif ('single' == $filename){
                $page_title
= $GLOBALS['_LANG']['single'] . '_' . $page_title;
                $ur_here 
.= ' <code>></code> <a href="single.php">' .
            $GLOBALS['_LANG']['single'] . '</a>';
          }

【2】找到语言包languages/zh_cn/common.php
在最尾部加上代码:
/* 新增单页面语言项
*/
$_LANG['single'] = '新增单页面';