0 463 2021-01-14 20:45:23
收藏帝国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
如果您认可我们的分享,有意与我们合作开展帝国cms网站建设与开发业务或插件定制,请联系右侧在线客服。我们能给您的,就是高质量的模板与售后。
标注了信息来源为下载鸥的文章皆为原创,如果是转载的优质文章,我们也都标注了出处。如果您喜欢我们的文章,请按照下载鸥所标注的文章出处进行标注,谢谢您的配合。
帝国cms是一款功能极为强大的cms程序,性能强悍、安全性高,可轻松支持10万数据,高级开发人员可制作出能容纳千万数据量的网站,是国内最出色的开源cms程序之一,推荐企业用户使用。
当前最新版本为7.5,8.0版本即将上线,新版本的核心优化点在于多终端的适配。
最近发现想要用帝国CMS开发博客的客户越来越多,但帝国cms本身更多的是支持企...
部分功能型站点需要验证访客ip,如非白名单ip需要禁止访问。从动态站点的角度...
如今phpcms由于停止更新不能继续用下去了,我们就更加推荐帝国。那么,phpcms可...
在帝国cms的开发应用中,标题作为文章的主体往往需要表意明显才能获得更好的...
很多网友在新增信息之后发现首页看不到栏目也看不到,于是开始点刷新刷新内容...
现如今,许多商家通过机器批量给网站发留言,一条两条还可以接受,有的商家却是拼...
如果平时喜欢挂着帝国cms网站后台不关闭,又留心了网站日志的朋友就会发现DoT...
在帝国cms开发过程中,我们经常会遇到这样那样的需求。就如栏目信息的展示,有...
现在市面上也有许多的完善的小说系统了,今天来分享下利用帝国CMS如何开发小...
帝国cms下载链接会先有一个跳转,点击后才能进行下载。那么,帝国cms怎样开启直...
PC端下上传的内容图片一般比较大,在移动端下加载会很慢,此时我们需要把这些图...
本次帝国CMS统计专题信息数量教程主要讲的是列表页list.var的代码写法。其...
tag页作为站点文章的高度聚合页,合理运用相当于站点附带了非常多的栏目,且内...
帝国CMS发布信息时,会默认从详情内容中截取前面一段内容作为简介,但有时会截...
通过本教程可以实现在帝国CMS内容页,如果信息有下载则显示,没有下载则不显示...
如今网站安全越来越重视,未配置SSL证书的域名容易被劫持,所以,建议广大站长尽...