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

2023-11-16 0 110

1、打开 \source\class\block\portal\block_article.php 文件
找到
function getdata($style, $parameter)
修改为
function getdata($style, $parameter, $bid)
找到
$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、打开 \source\function\function_block.php 文件
找到
if($forceupdate) {
          block_updatecache($bid, true);
          $block = $_G[‘block’][$bid];
     }

在其上方加入:
//如果是首页最新文章,去掉缓存
    if ($bid == 53) {
        $forceupdate = 1;
    }

找到
$return = $obj->getdata($thestyle, $block[‘param’]);
修改为
$return = $obj->getdata($thestyle, $block[‘param’],$bid);

3、打开 \source\function\function_core.php 文件
找到 function block_display($bid) 方法
在其方法内的尾部加入:
//翻页更改
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;
}

至此,修改完成。

版权所属:傲刃服务商城

傲刃服务 Discuz教程 discuz门户diy实现翻页功能的方法 https://www.lowcodebbs.com/269.html

常见问题
  • 部署服务[500元]:提供代码部署服务,提供技术咨询客服
    一条龙服务[3000元]:包含 价值1799的云服务器、域名、SSL证书、备案服务、小程序免300认证开通、特约商户申请、支付接口申请等服务保障您系统的正常上线,如需软著、应用上架、提升服务器配置则另外收取费用。
查看详情
发表评论
暂无评论