官方文章内容分页没有完善,特完善了一下,加入总页数和当前页,当前页显示class="on"
<?php
echo('<div class="content">');/*文章内容开始*/
$contents=explode('<hr style="page-break-after:always;" class="ke-pagebreak" />',$article['content']);/*判断是否有分页符*/
if(isset($_GET['p'])) {
if(isset($contents[$_GET['p']])) {
echo($contents[$_GET['p']]);
}else {
echo('此文章内容已经没有了');
}
}else {
echo($contents[0]);
}
echo('</div>');/*文章内容结束*/
/*文章分页开始*/
if (empty($contents[1])==''){/*判断是否有分页*/
$total = count($contents);/*总页数*/
$nowpage = isset($_GET['p'])&& $_GET['p']?$_GET['p']:1-1;/*当前页*/
echo('<div class="content_page"><ul>');
foreach($contents as $key=>$val) {
if($key == $nowpage){
echo('<li class="on"><a href="'.$article['id'].'_'.$key.'.html" title="第'.($key+1).'页">'.($key+1).'</a></li>');
}else{
echo('<li><a href="'.$article['id'].'_'.$key.'.html" title="第'.($key+1).'页">'.($key+1).'</a></li>');
}
}
echo('</ul></div>');
}/*文章分页结束*/
?>
这个代码往那弄呀?
怎么添加?