phpcms–分页修改

网站添加英文版,但是语言包是中文的(语言包配置修改文件是:【caches】-》【configs】-》system.php文件中的{‘lang’ => ‘zh-cn’,  //网站语言包}部分)

 

语言包的主要文件是【phpcms】-》【languages】-》【zh-cn】-》system.lang.php

修改如下:

$LANG[‘page_item’] = ‘条’;
$LANG[‘previous’] = ‘上一页’;
$LANG[‘next’] = ‘下一页’;
$LANG[‘en_page_item’] = ‘ total’;
$LANG[‘en_previous’] = ‘previous’;
$LANG[‘en_next’] = ‘next’;

把中文部分复制一份添加一个英文版

 

修改分页函数【phpcms】-》【libs】-》【functions】-》global.func.php里的pages()函数

复制一份修改成en_pages,如下所示

function en_pages($num, $curr_page, $perpage = 20, $urlrule = ”, $array = array(),$setpages = 10) {
if(defined(‘URLRULE’) && $urlrule == ”) {
$urlrule = URLRULE;
$array = $GLOBALS[‘URL_ARRAY’];
} elseif($urlrule == ”) {
$urlrule = url_par(‘page={$page}’);
}
$multipage = ”;
if($num > $perpage) {
$page = $setpages+1;
$offset = ceil($setpages/2-1);
$pages = ceil($num / $perpage);
if (defined(‘IN_ADMIN’) && !defined(‘PAGES’)) define(‘PAGES’, $pages);
$from = $curr_page – $offset;
$to = $curr_page + $offset;
$more = 0;
if($page >= $pages) {
$from = 2;
$to = $pages-1;
} else {
if($from <= 1) {
$to = $page-1;
$from = 2;
} elseif($to >= $pages) {
$from = $pages-($page-2);
$to = $pages-1;
}
$more = 1;
}
$multipage .= ‘<a class=”a1″>’.$num.L(‘en_page_item’).'</a>’;
if($curr_page>0) {
$multipage .= ‘ <a href=”‘.pageurl($urlrule, $curr_page-1, $array).'” class=”a1″>’.L(‘en_previous’).'</a>’;
if($curr_page==1) {
$multipage .= ‘ <span>1</span>’;
} elseif($curr_page>6 && $more) {
$multipage .= ‘ <a href=”‘.pageurl($urlrule, 1, $array).'”>1</a>..’;
} else {
$multipage .= ‘ <a href=”‘.pageurl($urlrule, 1, $array).'”>1</a>’;
}
}
for($i = $from; $i <= $to; $i++) {
if($i != $curr_page) {
$multipage .= ‘ <a href=”‘.pageurl($urlrule, $i, $array).'”>’.$i.'</a>’;
} else {
$multipage .= ‘ <span>’.$i.'</span>’;
}
}
if($curr_page<$pages) {
if($curr_page<$pages-5 && $more) {
$multipage .= ‘ ..<a href=”‘.pageurl($urlrule, $pages, $array).'”>’.$pages.'</a> <a href=”‘.pageurl($urlrule, $curr_page+1, $array).'” class=”a1″>’.L(‘en_next’).'</a>’;
} else {
$multipage .= ‘ <a href=”‘.pageurl($urlrule, $pages, $array).'”>’.$pages.'</a> <a href=”‘.pageurl($urlrule, $curr_page+1, $array).'” class=”a1″>’.L(‘en_next’).'</a>’;
}
} elseif($curr_page==$pages) {
$multipage .= ‘ <span>’.$pages.'</span> <a href=”‘.pageurl($urlrule, $curr_page, $array).'” class=”a1″>’.L(‘en_next’).'</a>’;
} else {
$multipage .= ‘ <a href=”‘.pageurl($urlrule, $pages, $array).'”>’.$pages.'</a> <a href=”‘.pageurl($urlrule, $curr_page+1, $array).'” class=”a1″>’.L(‘en_next’).'</a>’;
}
}
return $multipage;
}

 

然后修改【phpcms】-》【libs】-》【classes】-》template_cache.class.php

$str .= ‘$pages = pages($’.$op.’_total, $page, $pagesize, $urlrule);’;
在这行的下面加上
$str .= ‘$en_pages = en_pages($’.$op.’_total, $page, $pagesize, $urlrule);’;
$str .= ‘$r = $get_db->sql_query(“‘.$sql.'”);$s = $get_db->fetch_next();$pages=pages($s[\’count\’], $page, $pagesize, $urlrule);’;
在他下面增加:
$str .= ‘$r = $get_db->sql_query(“‘.$sql.'”);$s = $get_db->fetch_next();$en_pages=en_pages($s[\’count\’], $page, $pagesize, $urlrule);’;

 

 

最后在模板中直接用就可以了,如下

把  :<div id=”pages” class=”text-c”>{$pages}</div>

改成:<div id=”pages” class=”text-c”>{$en_pages}</div>

文章链接:,本站部分内容来自互联网,如不慎侵害的您的权益,请告知,我们将尽快删除!

发表评论