找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 156|回复: 0

[cms教程] discuz门户diy实现翻页功能的方法

[复制链接]

该用户从未签到

发表于 2016-1-14 09:23:30 | 显示全部楼层 |阅读模式

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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 = ""
        . ".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';
        }else{
        $html.='[*,[url=,'.$i.'[/url]';
        }
    }
    }else{
    for($i=$page-9;$i';
    }
    $html.='[*,[url=,'.$page.'[/url]';
    for($i=$page+1;$i';
    }
    }
   $html .= "
";
   echo $html;
}

至此,修改完成。
回复

使用道具 举报

网站地图|页面地图|文字地图|Archiver|手机版|小黑屋|找资源 |网站地图

GMT+8, 2024-10-5 13:18

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表