首先找到并打开/plus/List.PHP文件,在里面找到如下代码:
require_once(dirname(__file__)."/../include/common.inc.PHP");
在其下面添加如下代码:
if(isset($_GET['AJAX'])){ $typeID = isset($_GET['typeID']) ? intval($_GET['typeID']): 0;//传递过来的分类ID $page = isset($_GET['page']) ? intval($_GET['page']): 0;//页码 $pagesize = isset($_GET['pagesize']) ? intval($_GET['pagesize']): 15;//每页多少条,也就是一次加载多少条数据 $start = $page>0 ? ($page-1)*$pagesize : 0;//数据获取的起始位置。即limit条件的第一个参数。 $typesql = $typeID ? " WHERE typeID=$typeID" : '';//这个是用于首页实现瀑布流加载,因为首页加载数据是无需分类的,所以要加以判断,如果无需 $total_sql = "SELECT COUNT(ID) as num FROM `dede_archives` $typesql "; $temp = $dsql->Getone($total_sql); $total = 0;//数据总数 $load_num =0; if(is_array($temp)){ $load_num= round(($temp['num']-15)/$pagesize);//要加载的次数,因为默认已经加载了 $total = $temp['num']; } $sql = "SELECT a.*,t.typedir,t.typename,t.isdefault,t.defaultname,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath FROM `dede_archives` as a JOIN `dede_arctype` AS t ON a.typeID=t.ID $typesql ORDER BY ID DESC liMIT $start,$pagesize"; $dsql->Setquery($sql); $dsql->Execute('List'); $statu = 0;//是否有数据,默认没有数据 $data = array(); $index = 0; while($row = $dsql->GetArray("List")){ $row['info'] = $row['info'] = $row['infos'] = cn_substr($row['description'],160); $row['ID'] = $row['ID']; $row['filename'] = $row['arcurl'] = GetfileUrl($row['ID'],$row['typeID'],$row['senddate'],$row['Title'],$row['ismake'],$row['arcrank'],$row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']); $row['typeurl'] = GetTypeUrl($row['typeID'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['sitepath']); if($row['litpic'] == '-' || $row['litpic'] == ''){ $row['litpic'] = $GLOBALS['cfg_CMSpath'].'/images/defaultpic.gif'; } if(!preg_match("#^http:\/\/#i",$row['litpic']) &&$GLOBALS['cfg_multi_site'] == 'Y'){ $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; } $row['picname'] = $row['litpic'];//缩略图 //$row['stime'] = GetDateMK($row['pubdate']); $row['stime'] = date('Y-m-d H:i',$row['pubdate']); $row['click'] = $row['click']; $row['typelink'] = "".$row['typename']."";//分类链 $row['fullTitle'] = $row['Title'];//完整的标题 $row['shortTitle'] = $row['shortTitle'];//副标题 $row['Title'] = cn_substr($row['Title'],80);//截取后的标题 $data[$index] = $row; $index++; } if(!empty($data)){ $statu = 1;//有数据 } $result =array('statu'=>$statu,'List'=>$data,'total'=>$total,'load_num'=>$load_num); echo Json_encode($result);//返回数据 exit();} |
在需要无限加载的模板里引用下面这个Js代码,也可以把Js下载下来放你的网站加载,这里使用百度的外链,节省资源:
总结以上是内存溢出为你收集整理的dedecms利用ajax实现瀑布流下拉无限加载的教程jquery全部内容,希望文章能够帮你解决dedecms利用ajax实现瀑布流下拉无限加载的教程jquery所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)