dedecms首页 点击加载更多 怎么实现

 我来答
匿名用户
2016-07-22
展开全部
使用方法:
1、加载是用AJAX,需要先引用jQuery
2、模板在arcajax.php第二十八行请自行按需修改
3、arcajax.php放到plus目录下

HTML和js代码:
<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;// 栏目ID
if(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);//数据显示到页面
_this.attr("pnum", Number(pnum)+1);//分页+1
}else{
_this.text("没有更多的数据");
_this.attr("pnum", 0)
}
$("#loading27").hide();
}
})
return false;
})
</script>
PHP代码(arcajax.php):
<?php
require_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 = '';
//通过页面及总数解析当前页面数据范围
$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>';//模板

//处理列表内容项
$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 `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id
WHERE 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();
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式