下载鸥 > 网站下载 > 开发教程 > 帝国CMS

帝国CMS二次开发下拉加载更多教程

586 2021-01-14 20:45:23

收藏

简述

帝国cms下拉加载更多方式如下。

帝国cms一般是支持分页模式,但下拉加载更多无疑更有技术感。那么,怎样做下拉加载更多呢?

首先调用20条默认的信息,代码如下

<section class="FConBig">
    <div class="divcon">
        <div id="divcon1">
[e:loop={"select * from phome_ecms_newswhereclassidin(2,3,4,5,6)orderbynewstimedesclimit20",6,24,0}]
            <dlclass="FConSmall">
            <dt><a href="<?=$bqsr['titleurl']?>"><img src="<?=$public_r['add_phome_url']?><?=$bqr['titlepic']?>"width="100%"></a></dt>
            <dd><a href="<?=$bqsr['titleurl']?>"class="FConWza"><span class="FConWzTag"><?=$bqsr[classname]?></span><span class="FConTimeIco"></span><span class="FConWzTime"><?=date('Y-m-d',$bqr[newstime])?></span></a><a href="<?=$bqsr['titleurl']?>"class="FConWzDesc"><?=$bqr['title']?></a></dd>
            </dl>
[/e:loop]
        </div>
    </div>
</section>

<div class="FConBig"id="paiList"></div>
<div id="divcon2"><div id="divload"></div></div>
然后再是下拉加载的JS代码,

<scriptsrc="/Style/js/jquery-1.7.1.min.js"></script>
<scriptlanguage="javascript"type="text/javascript">
$(document).ready(function(){
    varpage=1;//这个不是真正的页数,而是位移量
    varnextpage=1;
    
    varwan=true;
    vartotalheight=0;
functionloadData(){
    totalheight=parseFloat($(window).height())+parseFloat($(window).scrollTop());
    if($(document).height()<=totalheight&&wan==true){//说明滚动条已达底部
        varcid=0;
        page=nextpage;
        $.ajax({
            url:'/Style/getajax.php',
            type:'get',
            data:{"classid":cid,'next':page},
            dataType:'html',
            beforeSend:function(){
                $('#divload').html('<div id="pullUp"><p class="pullUpLabela"><img src="/Style/css/img/wait1.gif"width="20"><span>正在载入</span></p></div>');
                $('#divcon2').show();
                wan=false;
            },
            success:function(str){
                if(str!=""){
                    $('#divcon1').show();
                    $('#divcon2').hide();
                    $('#divcon1').append(str);
                    nextpage++;
                    wan=true;
                }else{
                    $('#divload').html('<div id="pullUp"><span class="pullUpLabel">加载完毕!</span></div>');
                    $('#divcon2').show();
                }
            }
        });
    }}
    $(window).scroll(function(){
loadData();

});
})
</script>
最后就是getajax.php的加载代码

<?php
$ye=strFilter($_GET["next"]);
$clasid=strFilter($_GET["classid"]);

if($clasid==1){$clasid="2,3,4,5,6";}
if($clasid==7){$clasid="8,9,10,11,12,13";}
if($clasid==14){$clasid="15,16,17";}
if($clasid==18){$clasid="19,20,21,22";}
if($clasid==23){$clasid="24,25,26,27,38";}
if($clasid==28){$clasid="29,30,31,32";}
if($clasid==33){$clasid="34,35,36,37";}
if($clasid==0){
$aabbccdd=base64_encode("select * from phome_ecms_news order by newstime desc");
}else{
$aabbccdd=base64_encode("select * from phome_ecms_news where classid in ($clasid) order by newstime desc");
}
functionstrFilter($str){
$str=str_replace('`','',$str);
$str=str_replace('·','',$str);
$str=str_replace('~','',$str);
$str=str_replace('!','',$str);
$str=str_replace('!','',$str);
$str=str_replace('@','',$str);
$str=str_replace('#','',$str);
$str=str_replace('$','',$str);
$str=str_replace('¥','',$str);
$str=str_replace('%','',$str);
$str=str_replace('^','',$str);
$str=str_replace('……','',$str);
$str=str_replace('&','',$str);
$str=str_replace('*','',$str);
$str=str_replace('(','',$str);
$str=str_replace(')','',$str);
$str=str_replace('(','',$str);
$str=str_replace(')','',$str);
$str=str_replace('-','',$str);
$str=str_replace('_','',$str);
$str=str_replace('——','',$str);
$str=str_replace('+','',$str);
$str=str_replace('=','',$str);
$str=str_replace('|','',$str);
$str=str_replace('','',$str);
$str=str_replace('[','',$str);
$str=str_replace(']','',$str);
$str=str_replace('【','',$str);
$str=str_replace('】','',$str);
$str=str_replace('{','',$str);
$str=str_replace('}','',$str);
$str=str_replace(';','',$str);
$str=str_replace(';','',$str);
$str=str_replace(':','',$str);
$str=str_replace(':','',$str);
$str=str_replace(''','',$str);
$str=str_replace('"','',$str);
$str=str_replace('“','',$str);
$str=str_replace('”','',$str);
$str=str_replace(',','',$str);
$str=str_replace(',','',$str);
$str=str_replace('<','',$str);
$str=str_replace('>','',$str);
$str=str_replace('《','',$str);
$str=str_replace('》','',$str);
$str=str_replace('.','',$str);
$str=str_replace('。','',$str);
$str=str_replace('/','',$str);
$str=str_replace('、','',$str);
$str=str_replace('?','',$str);
$str=str_replace('?','',$str);
returntrim($str);
}
require("../e/class/connect.php");
if(!defined('InEmpireCMS'))
{
exit();
}
require("../e/class/db_sql.php");
require("../e/class/q_functions.php");
$link=db_connect();
$empire=newmysqlquery();

$yema=$ye*20;
$query=@mysql_query(base64_decode($aabbccdd)."$yema,20")//执行SQL语句
ordie("SQL语句执行失败2");
while($rs=mysql_fetch_assoc($query)){
$src=$rs[id];
$xwclassid=$rs['classid'];
$xwtitle=$rs['title'];
$xwtitleurl=$rs['titleurl'];
$xwtitlepic=$rs['titlepic'];
$smalltext=$rs['smalltext'];
$newstime=$rs['newstime'];
$onclick=$rs['onclick'];
$tuurl=$public_r[add_phome_url];

$queryss=@mysql_query("select * from phome_enewsclass where classid='$xwclassid'")//执行SQL语句
or die("SQL语句执行失败3");
while($rstt=mysql_fetch_assoc($queryss)){$xwclassname=$rstt[classname];$xwclasspath=$rstt[classpath];}

?>
<dlclass="FConSmall">
<dt><a href="<?=$xwtitleurl?>"><img src="<?=$tuurl?><?=$xwtitlepic?>"width="100%"></a></dt>
<dd><a href="<?=$xwtitleurl?>"class="FConWza"><span class="FConWzTag"><?=$xwclassname?></span><span class="FConTimeIco"></span><span class="FConWzTime"><?=date('Y-m-d',$newstime)?></span></a><a href="<?=$xwtitleurl?>"class="FConWzDesc"><?=$xwtitle?></a></dd>
</dl>
<?php}?>
这段代码加了写判断栏目的功能,大家按格式自行修改吧。


这样,就可以实现帝国cms下拉加载更多了。

本文地址:https://xzo.com.cn/develop/empire/175.html

有帮助,很赞!

信息来源:精准像素
导出教程 下载word版教程
发表评论 共有条评论
关于帝国CMS


帝国cms是一款功能极为强大的cms程序,性能强悍、安全性高,可轻松支持10万数据,高级开发人员可制作出能容纳千万数据量的网站,是国内最出色的开源cms程序之一,推荐企业用户使用

当前最新版本为7.5,8.0版本即将上线,新版本的核心优化点在于多终端的适配。

推荐帝国CMS开发教程
帝国cms后台信息列表标题显示不完怎么办?
帝国cms后台信息列表标题显示不完怎么办?

帝国CMS后台信息列表标题文字字数默认是被控制过的,超出一行会截断,一些相对...

15 801
帝国CMS文章怎样插入短视频?
帝国CMS文章怎样插入短视频?

在这个短视频横行的年代,我们都知道一个短视频比文章比图片都要更加具有吸引...

1 557
帝国CMS怎样修改首页模板?
帝国CMS怎样修改首页模板?

网站在运营过程中难免要进行小小的修修改改,此时如果找人就比较麻烦,自己改试...

1 502
帝国cms下载判断设备环境安卓苹果并适配下载地址
帝国cms下载判断设备环境安卓苹果并适配下载地址

帝国cms静态站下载判断设备环境是安卓还是苹果,并自动适配下载地址,如果当前...

1 512
帝国cms怎样记录会员浏览信息历史记录?
帝国cms怎样记录会员浏览信息历史记录?

帝国cms论坛早已有了以cookie形式保存浏览量历史记录在客户端的插件,但这样...

7 556
帝国cms列表页怎样用自带函数自动生成缩略图?
帝国cms列表页怎样用自带函数自动生成缩略图?

如果列表页图片尺寸相对于标题图更小,我们就可以使用帝国cms自带的缩略图函...

0 401
帝国cms删除文章时不删除该文章所属的附件
帝国cms删除文章时不删除该文章所属的附件

帝国cms删除文章时往往非常彻底,不仅删除了数据库里的文章信息、生成的页面,...

0 512
帝国cms默认评论表情添加修改调用与删除
帝国cms默认评论表情添加修改调用与删除

帝国cms评论中默认的表情包是QQ表情,默认显示10个,可以添加可以修改,本文详细...

0 445
推荐插件
帝国cms自动生成文章新闻目录插件下载
帝国cms自动生成文章新闻目录插件下载

用户体验是我们的需求,百度蜘蛛的认可更是我们的需求。毕竟,没有收录排名,何来...

0 1188
帝国cms自动给正文关键词添加tag内链
帝国cms自动给正文关键词添加tag内链

帝国cms有自带的给关键词添加内链功能,但需要手动添加关键词,容易出现疏漏和...

0 879
帝国cms智能自动审核按星期几审核指定栏目带推送插件
帝国cms智能自动审核按星期几审核指定栏目带推送插件

采集站的必备资源是自动审核,要做到日收录也离不开定时发布。而本插件的自动...

0 1344
帝国cms在线考试系统模板插件
帝国cms在线考试系统模板插件

一直没看到好用的帝国cms在线考试插件,所以自己开发了一款。在线考试插件用...

0 1347
帝国cms百度AI图像去雾api接口对接插件
帝国cms百度AI图像去雾api接口对接插件

通过本插件,可以实现帝国cms网站对接百度云api实现图像去雾的功能。经过实际...

0 494
帝国cms网站会员登录与退出历史记录日志插件
帝国cms网站会员登录与退出历史记录日志插件

帝国cms默认只有上次登录时间与ip,没有一个记录清单,所以今天,我们分享这个帝...

0 449
帝国cms访问统计ip地址链接与封禁插件下载
帝国cms访问统计ip地址链接与封禁插件下载

下载鸥开发了这款帝国cms封禁ip插件,自动记录访问情况,让我们可以更快的识别...

0 1113
帝国cms批量添加后台用户插件
帝国cms批量添加后台用户插件

使用帝国cms的企业用户、新闻资讯类站点的用户很多,此类站点很多时候需要有...

0 836
客服QQ:341553759
扫码咨询 常见问题 >
官方交流群:90432500
点击加入