详情页

ECshop新增单页面模板的方法

时间:2024年01月31日

编辑:佚名

下面是如果在ECSHOP增加单页面的方法:
【第一】在根目录创建一个php文件,命名为single.php[注:single.php是我自定义的页面。]
添加如下代码:
<?php
/**
*
ECSHOP 体检中心文件
*
============================================================================
*
网站地址: http://www.ecshop.com;
*
----------------------------------------------------------------------------
*
这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
*
使用;不允许对程序代码以任何形式任何目的的再发布。
*
============================================================================
*
$Author: yanwei $
* $Id: single.php 2012-08-15 20:43
$
*/
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>体检中心</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'] = '新增单页面';
这样通过前台访问single.php就可以显示你的页面内容了,而且头部和尾部都是调用的!
相关文章
猜你需要