帝国CMS首页增加分页方法

优点:前台首页还是前台首页后面刷新自定义列表页不会把首页文件覆盖,根目录也不会多出很多/index_*.html文件。

方法如下:

1.第一步跟老方法还是差不多的 新增自定义列表页 文件存放目录:../../page/(可以自行修改喜欢)

2.打开/e/class/userfun.php添加自定义函数

function yeksylog_homepage() {
      //$ajaxpager=hRepPostStr($skyr[ajaxpager]);
      $ajaxpager='5';
      global $empire,$dbtbpre;
           $latestmu=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_news ");//获取新闻表文章数量
           $listsql=$empire->fetch1("select * from {$dbtbpre}enewsuserlist where listname='xiu-首页' limit 1");//listname='xiu-首页'  修改成你新增列表名称
                   $lencord=$listsql[lencord];
                   $pagenumber=ceil($latestmu/$lencord);
                 if($ajaxpager<=$pagenumber && $ajaxpager!=0){
                        $pagerumber=$ajaxpager;
                 }else{
                        $pagerumber=$pagenumber;
                 }
                $mostssql=sys_ReturnEcmsLoopBq(0,$pagerumber,3,0);//使用灵动标签 php原型循环
                $bqno=0;
                while($mostr=$empire->fetch($mostssql)){
                $mosstr=sys_ReturnEcmsLoopStext($mostr);
                $bqno++;
                   $is='<li class="active"><span>1</span></li>';
                   $pagenext='<li class="next-page"><a href="/page/index_2.html">下一页</a></li>';
                  
                  if($bqno>1) {
                   $pager.='<li><a href="/page/index_'.$bqno.'.html">'.$bqno.'</a></li>';
                   }
                   $lastpage='<li><a href="/page/index_'.$pagerumber.'.html">尾页</a></li>';
                   if($pagenumber>2) {
                   $nextyeskylog='<li><span> ... </span></li>';
                   }
                
                }
         {
            echo ''.$is.''.$pager.''.$nextyeskylog.''.$pagenext.''.$lastpage.'';
          }  
}

首页设置动态模式会自动更新页数,静态需要更新。

3.在首页模版合适位置放置函数<?php yeksylog_homepage();?>

完成!

另外一个方法:

<?
echo ‘<?php
define("EmpireCMSAdmin","1");
require("e/class/connect.php");
require("e/class/db_sql.php");
require("e/class/functions.php");
require("e/class/delpath.php");
require("e/class/copypath.php");
require("e/class/t_functions.php");
require("e/data/dbcache/class.php");
require("e/data/dbcache/MemberLevel.php");
$link=db_connect();
$empire=new mysqlquery();
$_GET["page"]=(int)$_GET["page"];
if($_GET["page"]<=1||$_GET["page"]==""){
$_GET["page"]=1;
}
$no=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_download"); //总条数
$pageno=18;//每页页数
$nopage=ceil($no/$pageno); //总页数
$_GET["page"]=$_GET["page"]>$nopage ? 1:$_GET["page"];
$startid=($_GET["page"]-1)*$pageno; //开始id
$limit ="limit".$startid.",".$pageno;
if($nopage<2){
$limit="";
}
$index="&nbsp;&nbsp;<a href=".$public_r[newsurl].">首页</a>&nbsp;&nbsp;";
$pageeof="&nbsp;&nbsp;<a href=".$public_r[newsurl]."?page=".$nopage.">尾页</a>&nbsp;&nbsp;";
if($_GET["page"]>1){
$page=$_GET["page"]-1;
$pagepri="&nbsp;&nbsp;<a href=".$public_r[newsurl]."?page=".$page.">上一页</a>&nbsp;&nbsp;";
}
else{
$pagepri="&nbsp;&nbsp;<a href=#>上一页</a>&nbsp;&nbsp;";
}
if($_GET["page"]<$nopage){
$page=$_GET["page"]+1;
$pagenext="&nbsp;&nbsp;<a href=".$public_r[newsurl]."?page=".$page.">下一页</a>&nbsp;&nbsp;";
}
else{
$pagenext="&nbsp;&nbsp;<a href=#>下一页</a>&nbsp;&nbsp;";
}
for($i=1;$i<=$nopage;$i++){
$selected="";
if($i==$_GET["page"]){
$selected="selected=selected";
}
$selectedlist.="<option value=".$public_r[newsurl]."?page=".$i." ".$selected.">第".$i." 页</option>";
}
?>‘;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>[!--pagetitle--]</title>
<meta name="keywords" content="[!--pagekey--]">
<meta name="description" content="[!--pagedes--]">
<link href="[!--news.url--]skin/kaoshi/css10down.css" rel="stylesheet" type="text/css">
<script src="[!--news.url--]skin/kaoshi/shu10.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript" src="[!--news.url--]skin/kaoshi/riqi.js"></script>
</head>
<body>
[!--temp.header--]
<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    [!--temp.zuo--]
    <td width="10"></td>
    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="420" valign="top">
<div class="downinlist">
<?
echo ‘<div class="pages"><?=$index?><?=$pagepri?><?=$pagenext?><?=$pageeof?>&nbsp;&nbsp;&nbsp;&nbsp;转到:<select name=select onchange="self.location.href=this.options[this.selectedIndex].value"><?=$selectedlist?></select></div>
<div style=" font-size:0; height:4px;"></div>
<?php
$r=$empire->query("select * from {$dbtbpre}ecms_download".$limit."");
while($list=$empire->fetch($r))
{
$titleurl=sys_ReturnBqTitleLink($list);
?>
<table width="420" border="0" cellpadding="5" cellspacing="1" bgcolor="#eeeeee">
  <tr>
    <td width="50" bgcolor="#FFFFFF"><font color=blue><?=date("m-d",$list["newstime"])?></font></td>
    <td width="270" bgcolor="#FFFFFF"><a href="<?=$titleurl?>" target="_blank"><?=$list["title"]?></a></td>
    <td width="50" align="center" bgcolor="#FFFFFF"><a href="<?=$public_r["newsurl"]?>e/DownSys/DownSoft/?classid=<?=$list["classid"]?>&id=<?=$list["id"]?>&pathid=0" target=balnk class="sixian" style="color:#F00">下载↓</a></td>
  </tr>
</table>
<?php
}
db_close();
$empire=null;
?>
<div class="pages"><?=$index?><?=$pagepri?><?=$pagenext?><?=$pageeof?>&nbsp;&nbsp;&nbsp;&nbsp;转到:<select name=select onchange="self.location.href=this.options[this.selectedIndex].value"><?=$selectedlist?></select></div>
‘;
?>
</div></td>
        <td>&nbsp;</td>
        <td width="339" valign="top">
<div style=" font-size:0; height:3px;"></div><table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" background="[!--news.url--]skin/kaoshi/ra.gif">
          <tr>
            <td width="3%">&nbsp;</td>
            <td width="64%" style="font-size:14px; color:#666666"><strong>热门下载</strong></td>
            <td width="33%">&nbsp;</td>
          </tr>
        </table>
   <div class="ra1">           
[e:loop={0,10,4,0}]
<a href=‘<?=$bqsr[titleurl]?>’ title=‘<?=$bqr[title]?>’ target=‘_blank’><?=$bqr[title]?></a><br />
[/e:loop]</div>
   <div style=" font-size:0; height:6px;"></div>
   <div class="downa2"><!–广告–></div>
   <div style=" font-size:0; height:6px;"></div><table width="100%" height="30" border="0" cellpadding="0" cellspacing="0" background="[!--news.url--]skin/kaoshi/ra.gif">
          <tr>
            <td width="3%">&nbsp;</td>
            <td width="64%" style="font-size:14px; color:#666666"><strong>推荐下载</strong></td>
            <td width="33%">&nbsp;</td>
          </tr>
        </table>
   <div class="ra1">[e:loop={0,10,5,0}]
<a href=‘<?=$bqsr[titleurl]?>’ title=‘<?=$bqr[title]?>’ target=‘_blank’><?=$bqr[title]?></a><br />
[/e:loop]</div>
</td>
      </tr>
    </table> </td>
  </tr>
</table>
<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="6"></td>
  </tr>
</table>
[!--temp.footer--]</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大头D

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值