制作ecshop中英文切换简繁切换版面
对于从事外贸的商城网站来说,外文版面必不可以少,如何使用ECSHOP进行商城网站建设时,能够在自己的网站上拥有中英文切换|简繁切换版面呢?
下面是实现ecshop中英文切换|简繁切换版面的方法:
- 打开ECSHOP程序,找到includds/init.php这个文件,然后用Dreamweaver cs5打开它;
- 使用快捷键“CTRL+F”查找以下这二段代码并将它们删除:
require(ROOT_PATH . 'languages/' . $_CFG['lang'] . '/common.php'); if ($_CFG['shop_closed'] == 1) { header('Content-type: text/html; charset='.EC_CHARSET); die( $_LANG['shop_closed'], $_CFG['close_comment'] ); }
- 再用快捷键“CTRL+F”找到以下这段代码:
if ((DEBUG_MODE & 1) == 1)
- 在这段代码的上方粘贴这段代码:
if (!defined('INIT_NO_USERS')) { include(ROOT_PATH . 'includes/cls_session.php'); $sess = new cls_session($db, $ecs->table('session'), $ecs->table('session_data')); define('SESS_ID', $sess->get_session_id()); }
- 在这段代码的下方粘贴下面的这段中英文切换和简繁体切换代码,用于实现中英文版面;
if(!empty($_REQUEST['lang'])){
$_SESSION['lang']=$_REQUEST['lang'];
}
if (!empty($_SESSION['lang']))
{
switch($_SESSION['lang']){
case 'zh_cn':
$_CFG['lang']="zh_cn";
break;
case 'zh_tw':
$_CFG['lang']="zh_tw";
break;
case 'en_us':
$_CFG['lang']="en_us";
break;
}
}
require(ROOT_PATH . 'languages/' . $_CFG['lang'] . '/common.php');
if ($_CFG['shop_closed'] == 1)
{
header('Content-type: text/html; charset='.EC_CHARSET);
die( $_LANG['shop_closed'], $_CFG['close_comment'] );
} - 最后就是在网页页面调用中英文切换的按钮了,一般情况下这个功能按钮都是放在网站的顶部的。所以我们用DW打开themes/default/library/page_header.lbi ,在
<div class="topNavR"></div>
位置上方使用以下的调用代码:
<a href="?lang=zh_cn">简体 </a>
<a href="?lang=zh_tw">繁体 </a>
<a href="?lang=en_us">英文 </a> - 到网站后台清空一下缓存,再查一下前台的页面效果了,就会多了中文简体,中文繁体,English的按钮。
1.在前台文件夹include中找到init.phP文件,然后找到:
然后再填写上面这些代码:
if($_GET['lang']&&in_array($_GET['lang'],array(‘zh_cn’,'en_us’,'zh_tw’)))
{
setcookie(‘lang’,$_GET['lang'],0);
header(“location:”.PHP_SELF);
}
$_CFG['lang']=$_COOKIE['lang']?$_COOKIE['lang']:’zh_cn’;///$_CFG['lang']=’en_us’;//英文版
//echo $_COOKIE['lang'];
/* 载入语言文件 */
//$_CFG['lang']=$_GET['lang'];
require(ROOT_PATH . ‘languages/’ . $_CFG['lang'] . ‘/common.php’);
2.在找到头部模板文件
在 themes/default/library/page_header.lib 相应的位置(你自己需要的地方) 添加上对应的中文链接和英文链接,代码如下:
3.前台预览会出现Notice,和 Warning
Warning: Cannot modify header information – headers already sent by (output started at D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php:120) in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php on line 176
Warning: Cannot modify header information – headers already sent by (output started at D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php:120) in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php on line 177
Warning: Cannot modify header information – headers already sent by (output started at D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php:120) in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\cls_template.php on line 58
我们可以在init.php中屏蔽,在init.php的前几行找到(大概在20行。)
改成