栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > dedecms

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

dedecms 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

1、打开 sourceclassblockportalblock_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、打开 sourcefunctionfunction_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、打开 sourcefunctionfunction_core.php 文件 找到 function block_display($bid) 方法 在其方法内的尾部加入: //翻页更改 if($bid==53){     $page = $_REQUEST['page']?$_REQUEST['page']:1;     $html = ""         . ".page{padding:10px; float:left;}"         . ".page li{float:left; line-height:20px; padding:8px; font-size:16px;}"         . ".page li .on{color:#f57500; font-weight:800;}"         . "";     $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.mshxw.com
本文地址:https://www.mshxw.com/it/6434.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号