織夢(mèng)dedecms 首頁列表點(diǎn)擊加載更多ajax實(shí)現(xiàn)瀑布流效果
使用方法:
?1、加載是用AJAX,需要先引用jQuery
2、模板在arcajax.php第二十八行請(qǐng)自行按需修改
3、arcajax.php放到plus目錄下
HTML和js代碼:
PHP代碼(arcajax.php):?<div id="loading27">加載中</div><a href="javascript:;" id="getMore" pnum="2" class="index-more bgw mt15">瀏覽更多案例......</a><script type="text/javascript">$("#getMore").click(function(){var _this = $(this),pnum = _this.attr("pnum"),//分頁碼typeid = 1;// 欄目IDif(pnum == 0){return false;}$("#loading27").show();$.ajax({url: '/plus/arcajax.php',data: {typeid:typeid,pnum:pnum},success: function(data){if(data != ''){$(".index-list").append(data);//數(shù)據(jù)顯示到頁面_this.attr("pnum", Number(pnum)+1);//分頁+1}else{_this.text("沒有更多的數(shù)據(jù)");_this.attr("pnum", 0)}$("#loading27").hide();}})return false;})</script>
<?phprequire_once(dirname(__FILE__)."/../include/common.inc.php");require_once(DEDEINC.'/channelunit.class.php');require_once(DEDEINC.'/taglib/arcpagelist.lib.php');$pnum = empty($pnum)? 0 : intval(preg_replace("/[^\d]/",'', $pnum));$typeid = empty($typeid)? 0 : intval(preg_replace("/[^\d]/",'', $typeid));if($typeid==0 || $pnum==0) die(" Request Error! ");if($typeid > 0){$titlelen = AttDef($titlelen,30);$infolen = AttDef($infolen,160);$imgwidth = AttDef($imgwidth,120);$imgheight = AttDef($imgheight,120);$listtype = AttDef($listtype,'all');$arcid = AttDef($arcid,0);$channelid = AttDef($channelid,0);$orderby = AttDef($orderby,'default');$orderWay = AttDef($order,'desc');$subday = AttDef($subday,0);$line = $row;$artlist = '';//通過頁面及總數(shù)解析當(dāng)前頁面數(shù)據(jù)范圍$strnum = ($pnum-1) * 12;$limitsql = " LIMIT $strnum,12 ";$innertext = '<li [field:global name="autoindex" runphp="yes"]if(@me%3==0)@me=\'class="mrnone"\'; else @me="";[/field:global]><div><a href="[field:arcurl/]" title="[field:title/]"><img src="[field:litpic/]" width="278" height="245"></a></div><h3><a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a></h3><p>[field:description function="cn_substr(@me,150)"/]</p><span class="more"><a href="[field:arcurl/]">瀏覽案例</a></span></li>';//模板//處理列表內(nèi)容項(xiàng)$query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp ON arc.typeid=tp.idWHERE arc.typeid IN (".GetSonIds($typeid).") ORDER BY arc.sortrank desc $limitsql";$dsql->SetQuery($query);$dsql->Execute('al');$dtp2 = new DedeTagParse();$dtp2->SetNameSpace('field', '[', ']');$dtp2->LoadString($innertext);$GLOBALS['autoindex'] = 0;$ids = array();for($i=0; $i<12; $i++){for($j=0; $j<1; $j++){if($row = $dsql->GetArray("al")){$ids[] = $row['id'];//處理一些特殊字段$row['info'] = $row['infos'] = cn_substr($row['description'],$infolen);$row['id'] = $row['id'];if($row['corank'] > 0 && $row['arcrank']==0){$row['arcrank'] = $row['corank'];}$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:\/\/#", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y'){$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];}$row['picname'] = $row['litpic'];$row['stime'] = GetDateMK($row['pubdate']);$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".preg_replace("#['><]#", "", $row['title'])."'>";$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";$row['fulltitle'] = $row['title'];$row['title'] = cn_substr($row['title'],$titlelen);if($row['color']!='') $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";if(preg_match('#b#', $row['flag'])) $row['title'] = "<strong>".$row['title']."</strong>";//$row['title'] = "<b>".$row['title']."</b>";$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];$row['memberurl'] = $GLOBALS['cfg_memberurl'];$row['templeturl'] = $GLOBALS['cfg_templeturl'];if(is_array($dtp2->CTags)){foreach($dtp2->CTags as $k=>$ctag){if($ctag->GetName()=='array'){//傳遞整個(gè)數(shù)組,在runphp模式中有特殊作用$dtp2->Assign($k,$row);} else {if(isset($row[$ctag->GetName()])) $dtp2->Assign($k,$row[$ctag->GetName()]);else $dtp2->Assign($k,'');}}$GLOBALS['autoindex']++;}$artlist .= $dtp2->GetResult()."\r\n";}//if hasRowelse {$artlist .= '';}}//Loop Col}//loop line$dsql->FreeResult("al");} else{die(" Request Error! ");}AjaxHead();echo $artlist;
exit();
這樣就可以實(shí)現(xiàn)列表頁無限加載,如果需要首頁無限加載最新文章,刪除typeid相關(guān)的代碼即可!
相關(guān)文章:
-
帝國(guó)CMS是什么程序 帝國(guó)CMS是一套開源的靜態(tài)頁面程序,憑借超高的擴(kuò)展性,很多知名的新聞?wù)军c(diǎn)、行業(yè)站點(diǎn)都是應(yīng)用的帝國(guó)CMS后端。因?yàn)榈蹏?guó)CMS和dedecms一樣都是生成靜態(tài)頁面的,所以非常利于...
-
域名解析DNS分為顯性URL和隱形URL,顯性URL和隱形URL有什么區(qū)別?隱形URL和顯性URL哪個(gè)更有利于SEO?顯性URL相當(dāng)于域名了302重定向,隱形URL使用iframe框架技術(shù)隱藏真實(shí)目標(biāo)地址,顯性URL更有利于...
-
在常見的CMS系統(tǒng)中,我對(duì)dedecms算是比較熟悉的,自己網(wǎng)站用的也是這個(gè)系統(tǒng)。系統(tǒng)功能強(qiáng)大使用靈活,相信這也是它受到大多數(shù)中小站長(zhǎng)青睞的原因。 再好的系統(tǒng)也有照顧不周的地方,很多站...
-
這篇文章主要為大家詳細(xì)介紹了dedecms后臺(tái)增加php導(dǎo)出excel功能實(shí)現(xiàn)辦法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,有需要的朋友可以收藏方便以后借鑒。 不少朋友希望織夢(mèng)的后臺(tái)...
-
第一次使用的插件是 pdfobject.js 百度網(wǎng)盤下載地址:http://pan.baidu.com/s/1kUPhYdT 加載 script src=/style/js/pdfobject.js /script script type=text/javascript window.onload = function (){ var success = new PDFObject({ url: pdf文件地...
-
網(wǎng)上有一種方法是copy+unlink來移動(dòng)文件,但是遇到大文件時(shí)會(huì)消耗大量時(shí)間,對(duì)性能不怎么友好,可以使用rename()來移動(dòng)文件,速度非???關(guān)于rename()函數(shù) bool rename ( string $oldname , string $newname...
-
基于我們公司可選的幾種推廣方式: 一、關(guān)鍵詞優(yōu)化排名推廣(推薦) 指定關(guān)鍵詞推廣,按天付費(fèi),推廣我們業(yè)務(wù)中最重要的一些關(guān)鍵詞,達(dá)到百度首頁才收費(fèi),大概一個(gè)關(guān)鍵詞10元/天左右。...
-
插件介紹 wordpress程序網(wǎng)站在發(fā)布文章時(shí)可以給每一片文章添加與之相關(guān)的TAG標(biāo)簽,對(duì)于TAG標(biāo)簽可以生成很多頁面,增加搜索引擎對(duì)內(nèi)容的抓取量。 WP Auto Keywords插件就是一款能自動(dòng)給文章添加...
-
5.7 生成列表頁 改動(dòng) include/arc.listview.class.php 1.先設(shè)置 關(guān)閉副欄目(在系統(tǒng)----系統(tǒng)基本參數(shù)性能選項(xiàng)里) 2.一般網(wǎng)站不需要 欄目交叉 交叉 所以 找到94行注釋掉: //獲得交叉欄目ID /*if($this-Type...
-
使用preg_replace將刪除所有空白(包括制表符等) $string = user na me $string = preg_replace(/\s+/, , $string); echo $string; // username preg_replace(/\s/u, ,$string) u (PCRE8) 此修正符打開一個(gè)與perl不兼容的附加功能. 模式...