如何修改phpcms列表分页显示语言

更新时间:2022-11-23 11:55:57 来源:未知 作者:青锋建站
  在使用phpcms v9建站过程中,如果是外贸站,一般列表分页的页码显示是英文的,而中文站希望页面和分页列表希望是中文的,另外有时候还需要自定义,这就涉及到Phpcms V9列表分页自定义页码文字与修改语言的方法。

phpcms修改分页样式

<div id="pages" class="text-c">{$pages } </div>
  我们可以修改class来自定义样式,当然有人会说,这个只能修改div的样式,无法修改里面的内容的样式,其实之需要看一下这段代码解析出来的实际代码就知道了,而这里的样式可以直接通过head部分内读取的CSS来代替,我就可以在CSS里面添加这样一段,为了方便测试,我直接写在head标签内:
.text-c {margin:10px 0; }
.text-c a {padding:5px;margin:0 8px;border:1px solid #ccc;background-color:#eee; }

修改分布代码

  {$pages } 输出的分页效果是固定的,如何让他能够满足自己的需求,比如最简单的系统默认是显示多少条,用上一页,下一页。
phpcms/languages/zh-cn/system.lang.php
phpcms/libs/functions/global.func.php
phpcms/lib/classes/template_cache.class.php
1、修改system.lang.php
首先打开system.lang.php,找到29行LANG['next'] = ‘下一页’;处,你可以在下面插入自定义的内容,比如向后翻,向前翻,整理效果应该是这样的,添加完后保存可以关闭了。
$LANG['page_item'] = '条';
$LANG['previous'] = '上一页';
$LANG['next'] = '下一页';
$LANG['page_item_my'] = '篇'; //自定义
$LANG['previous_my'] = '向前翻'; //自定义
$LANG['next_my'] = '向后翻'; //自定义
2、修改global.lang.php
  然后打开global.func.php,搜索分页函数找到找到function pages…,在这个函数后复制原函数并修改添加自己想要定义的函数,例如:
//自定义分页函数
function pages_my($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('page_item_my').'</a>';
if($curr_page>0) {
$multipage .= ' <a href="'.pageurl($urlrule, $curr_page-1, $array).'" class="a1">'.L('previous_my').'</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('next_my').'</a>';
} else {
$multipage .= ' <a href="'.pageurl($urlrule, $pages, $array).'">'.$pages.'</a> <a href="'.pageurl($urlrule, $curr_page+1, $array).'" class="a1">'.L('next_my').'</a>';
}
} elseif($curr_page==$pages) {
$multipage .= ' <span>'.$pages.'</span> <a href="'.pageurl($urlrule, $curr_page, $array).'" class="a1">'.L('next_my').'</a>';
} else {
$multipage .= ' <a href="'.pageurl($urlrule, $pages, $array).'">'.$pages.'</a> <a href="'.pageurl($urlrule, $curr_page+1, $array).'" class="a1">'.L('next_my').'</a>';
}
}
return $multipage;
}
3、修改template_cache.class.php
最后打开template_cache.class.php,找到
$str .= ‘$pages = pages($’.$op.’_total, $page, $pagesize, $urlrule);’;
在下面添加:
$str .= '$pages_my= pages_my($'.$op.'_total, $page, $pagesize, $urlrule);';

当然如果使用过程中,发现SQL分页的不能正常使用,再在
$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();$pages_my=pages_my($s['count'], $page, $pagesize, $urlrule);';

分页调用方式

接下来,你只用在你想要的模板的分页出使用就可以了,例如开头的格式
<div id="pages" class="myListPage">{$pages_my } </div>
并写上对应的CSS就可以了。
  以上是青锋建站给大家分享的如何修改phpcms列表分页显示语言。青锋建站,提供专业的高品质网站制作服务,包括phpcms网站建设服务,SEO,网络营销,PHP开发,网站建设知名品牌,全国接单,专业做优化型网站,为企业构建营销平台。 

转载请注明来源网址:青锋建站-http://www.sjzphp.com/kaifazhe/phpcms/fenye_1534.html

电话 15632335515 | 邮箱 943703539@qq.com | QQ 943703539 | 微信 qingfengjianzhan

Copyright © 2016-2026 青锋建站 版权所有