织梦dede首页列表页,ajax加载更多,瀑布流,首页多栏目切换
效果图
加载更多按钮
一,模板上要引入jq文件
二,模板
".$row['typename']."";//分类链
$row['fulltitle']=$row['title'];//完整的标题
$row['shorttitle']=$row['shorttitle'];//副标题
$row['title']=cn_substr($row['title'], 60);//截取后的标题
$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();
}
时间:(2024-02-06 13:29:24)
本站资源均来自互联网或会员发布,如果不小心侵犯了您的权益请与我们联系。我们将立即删除!谢谢!
三,修改,plus/list.PHP 在require_once(dirname(__FILE__)."/");
的下面增加一段
if(isset($_GET['ajax'])){
$typeid=isset($_GET['typeid']) ? intval($_GET['typeid']): 0;//传递过来的分类ID
$orderby=isset($_GET['orderby']) ? intval($_GET['orderby']): 1;
//print_r($orderby);exit;
//1id排,2hot排序
$page=isset($_GET['page']) ? intval($_GET['page']): 0;//页码
$pagesize=isset($_GET['pagesize']) ? intval($_GET['pagesize']): 10;//每页多少条,也就是一次加载多少条数据
$start=$page>0 ? ($page-1)*$pagesize : 0;//数据获取的起始位置。即limit条件的***个参数。
$ntime2=gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
$limitday=$ntime2 - (40 * 24 * 3600);//40天内热文
$orwheres=" a.senddate > $limitday ";
//$typesql=$typeid ? " WHERE typeid=$typeid" : '';
if($orderby==1){//id降序
$typesql=$typeid ? " WHERE typeid=$typeid" : '';
} else{//hot排序
$typesql=$typeid ? " WHERE typeid=".$typeid." and ".$orwheres : " WHERE ".$orwheres;
}
//这个是用于首页实现瀑布流加载,
//因为首页加载数据是无需分类的,所以要加以判断,如果无需
$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']-$pagesize)/$pagesize);//要加载的次数,因为默认已经加载了
$total=$temp['num'];
}
if($orderby==1){//新
$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";
}else{//热门
$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 click DESC LIMIT $start,$pagesize";
}
//echo "$sql";exit;
$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'],250);
$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("#", $row['litpic']) &&$GLOBALS['cfg_multi_site']=='Y'){
$row['litpic']=$GLOBALS['cfg_mainsite'].$row['litpic'];
}
$row['picname']=$row['litpic'];//缩略图
$row['writer']=$row['writer'];
$row['click']=$row['click'];
$row['stime']=GetDateMK($row['pubdate']);
$row['timeago']=timeago($row['pubdate']);
$row['typelink']="
时间:(2024-02-06 13:29:24)
本站资源均来自互联网或会员发布,如果不小心侵犯了您的权益请与我们联系。我们将立即删除!谢谢!