国产亚洲欧美人成在线,免费视频爱爱太爽了无码,日本免费一区二区三区高清视频 ,国产真实伦对白精彩视频

歡迎您光臨深圳塔燈網(wǎng)絡(luò)科技有限公司!
電話圖標(biāo) 余先生:13699882642

織夢dedecms首頁列表頁ajax點擊下拉加載更多文章瀑布流效果

發(fā)表日期:2017-10 文章編輯:小燈 瀏覽次數(shù):1798

織夢dedecms實現(xiàn)點擊下拉加載更多主要用到ajax技術(shù)。具體步驟如下:

一、首先找到并打開/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;//每頁多少條,也就是一次加載多少條數(shù)據(jù)$start = $page>0 ? ($page-1)*$pagesize : 0;//數(shù)據(jù)獲取的起始位置。即limit條件的第一個參數(shù)。$typesql = $typeid ? " WHERE typeid=$typeid" : '';//這個是用于首頁實現(xiàn)瀑布流加載,因為首頁加載數(shù)據(jù)是無需分類的,所以要加以判斷,如果無需$total_sql = "SELECT COUNT(id) as num FROM `archives` $typesql ";$temp = $dsql->GetOne($total_sql);$total = 0;//數(shù)據(jù)總數(shù)$load_num =0;if(is_array($temp)){$load_num= round(($temp['num']-15)/$pagesize);//要加載的次數(shù),因為默認已經(jīng)加載了$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.sitepathFROM `archives` as a JOIN `arctype` AS t ON a.typeid=t.id $typesql ORDER BY id DESC LIMIT $start,$pagesize";$dsql->SetQuery($sql);$dsql->Execute('list');$statu = 0;//是否有數(shù)據(jù),默認沒有數(shù)據(jù)$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['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$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'];//完整的標(biāo)題$row['shorttitle'] = $row['shorttitle'];//副標(biāo)題$row['title'] = cn_substr($row['title'], 80);//截取后的標(biāo)題$data[$index] = $row;$index++;}if(!empty($data)){$statu = 1;//有數(shù)據(jù)}$result =array('statu'=>$statu,'list'=>$data,'total'=>$total,'load_num'=>$load_num);echo json_encode($result);//返回數(shù)據(jù)exit();}
二、然后在需要使用瀑布流無線加載的織夢dedecms模板里引用下面這個js代碼(這個js大家應(yīng)該不是很陌生,只要有用到JQ庫函數(shù)的話一定要引用這個js):

<scriptsrc="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>

三、并在模板底部添加以下代碼:

<script type="text/javascript">var loadConfig = {url_api:'/plus/list.php',typeid:{dede:field name="typeid"/},page:2,pagesize:15,//這個就是滑動一次添加幾條信息的參數(shù)設(shè)置loading : 0,}functionloadMoreApply(){if(loadConfig.loading == 0){ var typeid = loadConfig.typeid; var page = loadConfig.page; var pagesize = loadConfig.pagesize; var url = loadConfig.url_api,data={ajax:'pullload',typeid:typeid,page:page,pagesize:pagesize}; var sTop = document.body.scrollTop || document.documentElement.scrollTop, dHeight = $(document).height(), cHeight = document.documentElement.clientHeight; console.log(dHeight); if (sTop + cHeight >= dHeight - cHeight) { loadConfig.loading = 1;function ajax(url, data) { $.ajax({url: url,data: data,async: false,type: 'GET',dataType: 'json',success: function(data) {addContent(data);}});}ajax(url,data);}}} function addContent (rs){if(rs.statu== 1){var data = rs.list;var total = rs.total;var arr=[];var length = data.length;for(var i=0;i<length;i++){arr.push('<a href="'+data[i].arcurl+'" title="'+data[i].title+'">');arr.push('<dl class="yz_card">');arr.push('<dt class="yz_card_dt">');arr.push('<img src="'+data[i].picname+'" alt="'+data[i].title+'">');arr.push('</dt>');arr.push('<dd class="yz_card_dd">');arr.push('<p class="yz_card_p">'+data[i].title+'</p>');arr.push('<div class="yz_card_icon">');arr.push('<span class="yz_comment">');arr.push(data[i].click);arr.push('<em class="yz_icon_comment"><img src="/templets/default/images/pingluan.png" height="14"></em>');arr.push('</span>');arr.push('</div>');arr.push('<div class="yz_datetime">'+data[i].stime+'</div>');arr.push('</dd>');arr.push('</dl>');arr.push('</a>');}$('.arclist').append(arr.join(''));loadConfig.load_num = rs.load_num;if(total<loadConfig.page*loadConfig.pagesize || loadConfig.page > loadConfig.load_num){window.removeEventListener('srcoll',loadMoreApply,false);}loadConfig.page++;loadConfig.loading = 0;}}function pullLoad(){window.addEventListener('scroll', loadMoreApply, false);}pullLoad();</script>
上面的代碼中的$('.arclist').append(arr.join(''));里的arclist對應(yīng)模板內(nèi)列表的外框class屬性。

arr.push部分對應(yīng)的是列表中單篇文章的代碼。

到此織夢dedecms瀑布流無限加載就實現(xiàn)了。


本頁內(nèi)容由塔燈網(wǎng)絡(luò)科技有限公司通過網(wǎng)絡(luò)收集編輯所得,所有資料僅供用戶參考了本站不擁有所有權(quán),如您認為本網(wǎng)頁中由涉嫌抄襲的內(nèi)容,請及時與我們聯(lián)系,并提供相關(guān)證據(jù),工作人員會在5工作日內(nèi)聯(lián)系您,一經(jīng)查實,本站立刻刪除侵權(quán)內(nèi)容。本文鏈接:http://m.jstctz.cn/11237.html
相關(guān)cms文章
 八年  行業(yè)經(jīng)驗

多一份參考,總有益處

聯(lián)系深圳網(wǎng)站公司塔燈網(wǎng)絡(luò),免費獲得網(wǎng)站建設(shè)方案及報價

咨詢相關(guān)問題或預(yù)約面談,可以通過以下方式與我們聯(lián)系

業(yè)務(wù)熱線:余經(jīng)理:13699882642

Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.