discuz门户diy实现翻页功能的方法

discuz门户diy实现翻页功能的方法

discuz 2016-05-18 10:23:53

discuz门户diy实现翻页功能的方法

分类: discuz时间: 2016-05-18

1、打开 sourceclassblockportalblock_article.php 文件
找到

function getdata($>function getdata($>$query = DB::query("SELECT at.*, ac.viewnum, ac.commentnum FROM ".DB::table('portal_article_title')." at LEFT JOIN ".DB::table('portal_article_count')." ac ON at.aid=ac.aid WHERE $wheresql$keyword ORDER BY $orderby LIMIT $startrow, $items");


在其上方加入:
//首页翻页修改
if($bid==53){
    $page = $_REQUEST['page']?$_REQUEST['page']:1;
    $startrow = ($page-1)*$items;
}

这里的bid为diy的记录id,查看方法可以通过firebug工具查看。此文中后面用到的bid均为此含义。

2、打开 sourcefunctionfunction_block.php 文件
找到

if($forceupdate) {
          block_updatecache($bid, true);
          $block = $_G['block'][$bid];
     }


在其上方加入:

//如果是首页最新文章,去掉缓存
    if ($bid == 53) {
        $forceupdate = 1;
    }


找到

$return = $obj->getdata($the>$return = $obj->getdata($the>//翻页更改
if($bid==53){
    $page = $_REQUEST['page']?$_REQUEST['page']:1;
    $html = "
";
    $html .= '
';
    if($page<11){
    for($i=1;$i<21;$i++){
        if($page == $i){
        $html.='
'.$i.'
';
        }else{
        $html.='
'.$i.'
';
        }
    }
    }else{
    for($i=$page-9;$i<$page;$i++){
        $html.='
'.$i.'
';
    }
    $html.='
'.$page.'
';
    for($i=$page+1;$i<$page+10;$i++){
        $html.='
'.$i.'
';
    }
    }
   $html .= "
";
   echo $html;
}


至此,修改完成。

小编极力推荐:


相关文章