欢迎光临
我们一直在努力

ECshop新增单页面模板的方法

今应客户的要求,需要增加一些单页面,但是ECSHOP却没有这个功能,通过在网上搜索都没有找到相关的信息,后经过思考,终于实现该功能。下面是如果在ECSHOP增加单页面的方法:

【第一】在根目录创建一个php文件,命名为single.php[注:single.php乃我自定义的页面。]
添加如下代码:

<?php

/**
 * ECSHOP 体检中心文件
 * ============================================================================
 * 网站地址: http://www.ywcms.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>
    <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>&gt;</code> <a href=”exchange.php”>’ .
                                $GLOBALS[‘_LANG’][‘exchange’] . ‘</a>’;
            }
            /* 其他的在这里补充 */

在积分兑换下面新增:
/* 新增单页面 */
            elseif (‘single’ == $filename)
            {
                $page_title = $GLOBALS[‘_LANG’][‘single’] . ‘_’ . $page_title;
                $ur_here   .= ‘ <code>&gt;</code> <a href=”single.php”>’ .
                                $GLOBALS[‘_LANG’][‘single’] . ‘</a>’;
            }
【2】找到语言包languages/zh_cn/common.php
在最尾部加上代码:
/* 新增单页面语言项 */
$_LANG[‘single’] = ‘新增单页面’;
这样通过前台访问single.php就可以显示你的页面内容了,而且头部和尾部都是调用的!

转自:严微网络科技有限公司

赞(0) 打赏
未经允许不得转载:刘旭的人个博客 » ECshop新增单页面模板的方法
分享到: 更多 (0)
标签:

评论 抢沙发

评论前必须登录!

 

QQ :13945502电话:13913571631

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

×
订阅图标按钮