首先調(diào)用20條默認(rèn)的信息,代碼如下
<section class="FConBig"> <p class="pcon"> <p id="pcon1"> [e:loop={"select * from www_11px_cn_ecms_news where classid in (2,3,4,5,6) order by newstime desc limit 20",6,24,0}] <dl class="FConSmall"> <dt><a href="<?=$bqsr['titleurl']?>"><img src="<?=$public_r['add_www_11px_cn_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] </p> </p> </section> <p class="FConBig" id="paiList"></p> <p id="pcon2"><p id="pload"></p></p>
然后再是下拉加載的JS代碼,
<script src="/Style/js/jquery-1.7.1.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function(){ var page = 1;//這個(gè)不是真正的頁數(shù),而是位移量 var nextpage = 1; var wan=true; var totalheight = 0; function loadData(){ totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); if ($(document).height() <= totalheight && wan==true) { // 說明滾動(dòng)條已達(dá)底部 var cid = 0; page = nextpage; $.ajax({ url : '/Style/getajax.php', type:'get', data:{"classid":cid,'next':page}, dataType : 'html', beforeSend:function(){ $('#pload').html('<p id="pullUp"><p class="pullUpLabela"><img src="/Style/css/img/wait1.gif" width="20"><span>正在載入</span></p></p>'); $('#pcon2').show(); wan=false; }, success : function(str){ if(str!=""){ $('#pcon1').show(); $('#pcon2').hide(); $('#pcon1').append(str); nextpage++; wan=true; }else{ $('#pload').html('<p id="pullUp"> <span class="pullUpLabel">加載完畢!</span></p>'); $('#pcon2').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 www_11px_cn_ecms_news order by newstime desc limit"); }else{ $aabbccdd = base64_encode("select * from www_11px_cn_ecms_news where classid in ($clasid) order by newstime desc limit"); } function strFilter($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); return trim($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=new mysqlquery(); $yema= $ye*20; $query = @mysql_query(base64_decode($aabbccdd)." $yema,20") //執(zhí)行SQL語句 or die("SQL語句執(zhí)行失敗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_www_11px_cn_url]; $queryss = @mysql_query("select * from www_11px_cn_enewsclass where classid='$xwclassid'") //執(zhí)行SQL語句 or die("SQL語句執(zhí)行失敗3"); while($rstt = mysql_fetch_assoc($queryss)){$xwclassname=$rstt[classname];$xwclasspath=$rstt[classpath];} ?> <dl class="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 } ?>
這段代碼加了寫判斷欄目的功能,大家按格式自行修改吧。
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 帝國CMS二次開發(fā)下拉加載更多教程