虚位以待(AD)
虚位以待(AD)
首页 > CMS教程 > Discuz! > discuz 门户diy实现翻页功能的修改记录

discuz 门户diy实现翻页功能的修改记录
类别:Discuz!   作者:码皇   来源:互联网   点击:

第一步:找到文件:sourceclassblockportalblock_article php找到这个方法:function getdata($style, $parameter)将其修改为:function getdata($style, $parameter, $bid)在本文件再找到这样一段话:php代码:$que ,魔客吧
第一步:找到文件:sourceclassblockportalblock_article.php

找到这个方法:function getdata($style, $parameter)

将其修改为:function getdata($style, $parameter, $bid)

在本文件再找到这样一段话:

[代码]php代码:

    $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");

在其上方加入:
//首页翻页修改

[代码]php代码:

    if($bid==53){
    $page = $_REQUEST['page']?$_REQUEST['page']:1;
    $startrow = ($page-1)*$items;
    }

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


第二部,找到文件sourcefunctionfunction_block.php

定位到这里:

[代码]php代码:

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

在其上方加入:

[代码]php代码:

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

在本文件,在查找这样一句话:

[代码]php代码:

    $return = $obj->getdata($thestyle, $block['param']);

将其修改为:

[代码]php代码:

    $return = $obj->getdata($thestyle, $block['param'],$bid);

第三步,找到文件:sourcefunctionfunction_core.php

定位到这个方法:function block_display($bid)

在其方法内的尾部加入:

[代码]php代码:

    //翻页更改 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;
    }


至此,修改完成,案例请查看:www.php2.cc





相关热词搜索: discuz 门户diy实现翻页功能的修改记录