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

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

498 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怎样设置TAG伪静态
帝国CMS怎样设置TAG伪静态

从优化的角度来说,帝国CMS的动态tag由于是带问号的URL,搜索引擎不大喜欢,收录...

11 1112
帝国CMS怎样做百万、千万级别数据库的网站?
帝国CMS怎样做百万、千万级别数据库的网站?

帝国CMS作为最强大的开源cms之一,其程序效率毫无疑问。但,帝国CMS真的可以做...

19 1258
帝国cms后台DoTimeRepage.php一直刷新写满日志了怎么办?
帝国cms后台DoTimeRepage.php一直刷新写满日志了怎么办?

如果平时喜欢挂着帝国cms网站后台不关闭,又留心了网站日志的朋友就会发现DoT...

1 536
帝国cms面包屑导航[!–newsnav–]修改方式大合集
帝国cms面包屑导航[!–newsnav–]修改方式大合集

本文介绍的帝国cms面包屑导航newsnav修改为newsnav完整的修改攻略,包括标签...

11 1947
帝国cms怎样判断会员是否登录的状态?
帝国cms怎样判断会员是否登录的状态?

许多站点需要做帝国cms会员投稿的功能,不仅可以借此盈利,还能有效促进seo排名...

0 320
帝国cms动态页、静态页、伪静态页有什么区别?
帝国cms动态页、静态页、伪静态页有什么区别?

我们知道,帝国cms既可以做动态页,也可以做静态页,还可以做伪静态页。那么,他们...

0 356
帝国CMS在JS调用登陆模板中调用会员头像
帝国CMS在JS调用登陆模板中调用会员头像

我们在开发帝国cms登陆模板时经常需要调用会员头像,但帝国CMS默认并没有提供...

0 325
帝国cms怎样在列表循环list.var中插入广告?
帝国cms怎样在列表循环list.var中插入广告?

帝国cms程序广泛应用于各行各业的网站建设,其安全性高、性能强大。但网站建...

3 410
推荐插件
帝国cms百度AI图像去雾api接口对接插件
帝国cms百度AI图像去雾api接口对接插件

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

0 365
帝国cms百度AI图像清晰度增强api接口对接插件
帝国cms百度AI图像清晰度增强api接口对接插件

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

0 419
帝国CMS内网用户静态站点文章访客统计插件
帝国CMS内网用户静态站点文章访客统计插件

本插件适用于内网用户,可查看单篇文章访问者ip地址。如果添加访问者ip组,可查...

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

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

0 655
帝国cms百度文字识别ocr接口对接插件
帝国cms百度文字识别ocr接口对接插件

许多网站会做一些小功能小插件给客户使用以增强用户黏性,比如图片转文字,这种...

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

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

0 863
帝国cms百度AI图像无损放大api接口对接插件
帝国cms百度AI图像无损放大api接口对接插件

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

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

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

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