一、面包屑导航主页替换成英文的方法:
{dede:field name='position' function='str_replace("主页","Home",@me)'/}
二、列表页分页替换成英文的方法:
1、打开include/arc.listview.class.php(本文以DedeCMS5.7为例)
找到(约29行)
var $remoteDir;在其下面加上一个新行
var $pagelang;找到(约528行)
$list_len = trim($ctag->GetAtt("listsize"));在其下面加上一个新行
$pagelang = trim($ctag->GetAtt("pagelang"));找到(约531行)
if($list_len=="")在其下面加上
{
$list_len = 3;
}
if($pagelang=="")修改(约545行)
{
$pagelang = 'cn';
}
$this->dtp->Assign($tagid,$this->GetPageListST($list_len,$listitem));为
$this->dtp->Assign($tagid,$this->GetPageListST($list_len,$listitem,$pagelang));
修改(新增)
function GetPageListST($list_len,$listitem="index,end,pre,next,pageno")为
function GetPageListST($list_len,$listitem="index,end,pre,next,pageno",$pagelang='cn')修改(约826行)
return "<li><span class=\"pageinfo\">共 <strong>1</strong> 页 <strong>".$this->TotalResult."</strong> 条记录</span></li>\r\n";为
if($pagelang=='cn') {修改
return "<li><span class=\"pageinfo\">共 <strong>1</strong> 页 <strong>".$this->TotalResult."</strong> 条记录</span></li>\r\n";
}
else
{
return "<li><span class=\"pageinfo\">Total <strong>1</strong> Page <strong> ".$this->TotalResult."</strong> Records</span></li>\r\n";
}
return "<li><span class=\"pageinfo\">共 <strong>0</strong> 页 <strong>".$this->TotalResult."</strong> 条记录</span></li>\r\n";为
if($pagelang=='cn') {修改
return "<li><span class=\"pageinfo\">共 <strong>0</strong> 页 <strong>".$this->TotalResult."</strong> 条记录</span></li>\r\n";
}
else
{
return "<li><span class=\"pageinfo\">Total <strong>0</strong> Page <strong> ".$this->TotalResult."</strong> Records</span></li>\r\n";
}
$maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong> 页 <strong>".$this->TotalResult."</strong> 条</span></li>\r\n";为
if($pagelang=='cn') {依照上面的方法,依次修改下面的获取上一页、主页、下一页、末页的内容
$maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong> 页 <strong>".$this->TotalResult."</strong> 条</span></li>\r\n";
}
else
{
$maininfo = "<li><span class=\"pageinfo\">Total <strong>{$totalpage}</strong> Page <strong> ".$this->TotalResult."</strong> Records</span></li>\r\n";
}
2、打开列表模板页面,我这以list_article_en.htm为例,其中list_article_en.htm为英文版的列表页面模板,中文版的可以不用修改
修改
{dede:pagelist listsize='5'/}为
{dede:pagelist pagelang='en' listsize='5'/}重新生成列表页成功。
三、文章内容页上一篇下一篇增加英文版
1.模板文件中调用的方法
li>{dede:prenext get='pre'/}</li>
<li>{dede:prenext get='next'/}</li>
更改为
<li>{dede:prenext get='pre' sitelang='en'/}</li>
<li>{dede:prenext get='next' sitelang='en'/}</li>
$this->dtp->Assign($i,$this->GetPreNext($ctag->GetAtt('get')));
更改为
$this->dtp->Assign($i,$this->GetPreNext($ctag->GetAtt('get'), $ctag->GetAtt('sitelang')));
3.然后再找函数 GetPreNext 找到
function GetPreNext($gtype='')
更改为
function GetPreNext($gtype='', $site_lang)
4.判断代码,写在
function GetPreNext($gtype='', $site_lang)
{到 $rs = '';中间
//添加在这里
$str_pre = '';
$str_next = '';
$str_pre_words = '';
$str_next_words = ''; if($site_lang == 'cn')
{
$str_pre = '上一篇';
$str_next = '下一篇';
$str_pre_words = '上一篇:没有了';
$str_next_words = '下一篇:没有了';
}elseif($site_lang == 'en')
{
$str_pre = 'Preview';
$str_next = 'Next';
$str_pre_words = 'Preview:no';
$str_next_words = 'Next:no';
}
5.然后将 if(is_array($preRow)) 里面的上一篇下一篇 上一篇:没有了,下一篇:没有换成变量,找到
$this->PreNext['pre'] = "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
改为
$this->PreNext['pre'] = $str_pre .":<a href='$mlink'>{$preRow['title']}</a> ";
找到
$this->PreNext['pre'] = "上一篇:没有了 ";
改为
$this->PreNext['pre'] = $str_pre_words;
找到
$this->PreNext['next'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
改为
$this->PreNext['next'] = $str_next . ":<a href='$mlink'>{$nextRow['title']}</a> ";
找到
$this->PreNext['next'] = "下一篇:没有了 ";
改为
$this->PreNext['next'] = $str_next_words;