1、dedecms首頁 點擊載入更多 怎麼實現
使用方法:
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();
2、dedecms列表實現點擊載入更多列表,求高手解答
這個思路很簡單做起來比較麻煩
在模板中做一個載入更多的按鈕,點擊後使用ajax去請求數據。
請求到數據後將數據添加到網頁對應的容器中。
請求的路徑你在plus目錄下新建一個php文件,也就是dedecms的插件目錄,
內容參開如下(我的瀑布流獲取數據插件):
require_once(dirname(__FILE__)."/../include/common.inc.php");
//$t1 = ExecTime();
$page = isset($_GET['page'])?$_GET['page']:1;
$per = isset($_GET['per'])?$_GET['per']:1;
$limit = (($page-1)*$per).",".$per;
$selquery = "SELECT * FROM `#@__archives` where channel=2 limit ".$limit;
$dsql->SetQuery($selquery);
$dsql->Execute();
while($row = $dsql->GetArray())
{
$arcurl = GetOneArchive($row['id']);
$arcurl = $arcurl['arcurl'];
$count = Getimgnum($row['id']);
$img = thumbImg($row['litpic'],235,0);
$title = $row['title'];
echo "<div class='pic_box'>
<a href='$arcurl' target='_blank' title='$title' class='img'>
<img rel='lazy' $img alt='$title' src='http://www.meinvmj.com/pic/none.gif' />
<div class='num'><i>$count</i><b>張</b></div>
</a>
<span>
<a href='$arcurl' target='_blank' title='$title'>$title</a>
</span>
</div>";
}
輸出內容就直接使用你的模板中的列表部分,數據在插件里直接填充。
每次獲取三條修改sql的limit即可
3、dedecms 列表點擊載入更多讀取資料庫內容怎麼實現
使用方法:
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();
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')
{
//傳遞整個數組,在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()."
";
}//if hasRow
else {
$artlist .= '';
}
}//Loop Col
}//loop line
$dsql->FreeResult("al");
} else
{
die(" Request Error! ");
}
AjaxHead();
echo $artlist;
exit();
4、織夢cms首頁如何實現 ajax載入更多,注意是首頁,而且是點擊載入,不是下拉。求高手,如圖那樣
這跟框架沒關系吧,建議你看一下前端框架layui 裡面有個流載入 有點擊載入跟下拉載入的 只需要下載好JS跟CSS放到你項目中 引入文件 復制文檔裡面的代碼就可以了
5、織夢文章頁載入慢.什麼原因
第一,伺服器慢;這是你的網站伺服器慢,打開肯定慢。
第二,網站文章頁有大圖,載入會比較慢;
第三,文章頁開頭的JS過多,載入JS是比較費時間的,可以把一些不需要先載入的JS放到底部去!
6、dedecms文章列表實現 點擊載入更多 ajax無刷新分頁
這個思路很簡單做起來比較麻煩在模板中做一個載入的按鈕,點擊後使用ajax去請求數據。請求到數據後將數據添加到網頁對應的容器中。請求的路徑你在plus目錄下新建一個php文件,也就是dedecms的插件目錄,內容參開如下(我的瀑布流獲取數據插件):require_once(dirname(__FILE__)."/../include/common.inc.php");//$t1=ExecTime();$page=isset($_GET['page'])?$_GET['page']:1;$per=isset($_GET['per'])?$_GET['per']:1;$limit=(($page-1)*$per).",".$per;$selquery="SELECT*FROM`#@__archives`wherechannel=2limit".$limit;$dsql->SetQuery($selquery);$dsql->Execute();while($row=$dsql->GetArray()){$arcurl=GetOneArchive($row['id']);$arcurl=$arcurl['arcurl'];$count=Getimgnum($row['id']);$img=thumbImg($row['litpic'],235,0);$title=$row['title'];echo"$count張$title";}輸出內容就直接使用你的模板中的列表部分,數據在插件里直接填充。每次獲取三條修改sql的limit即可
7、dedecms列表頁點擊更多載入列表
這個思路很簡單做起來比較麻煩
在模板中做一個載入更多的按鈕,點擊後使用ajax去請求數據。
請求到數據後將數據添加到網頁對應的容器中。
請求的路徑你在plus目錄下新建一個php文件,也就是dedecms的插件目錄,
內容參開如下(我的瀑布流獲取數據插件):
require_once(dirname(__FILE__)."/../include/common.inc.php");
//$t1 = ExecTime();
$page = isset($_GET['page'])?$_GET['page']:1;
$per = isset($_GET['per'])?$_GET['per']:1;
$limit = (($page-1)*$per).",".$per;
$selquery = "SELECT * FROM `#@__archives` where channel=2 limit ".$limit;
$dsql->SetQuery($selquery);
$dsql->Execute();
while($row = $dsql->GetArray())
{
$arcurl = GetOneArchive($row['id']);
$arcurl = $arcurl['arcurl'];
$count = Getimgnum($row['id']);
$img = thumbImg($row['litpic'],235,0);
$title = $row['title'];
echo "<div class='pic_box'>
<a href='$arcurl' target='_blank' title='$title' class='img'>
<img rel='lazy' $img alt='$title' src='http://www.meinvmj.com/pic/none.gif' />
<div class='num'><i>$count</i><b>張</b></div>
</a>
<span>
<a href='$arcurl' target='_blank' title='$title'>$title</a>
</span>
</div>";
}
輸出內容就直接使用你的模板中的列表部分,數據在插件里直接填充。
8、織夢5.7搭建完成頁面總是在不斷載入
你是在本地測試的嗎?文件是官方下載的嗎?按道理不會出現那樣的
9、織夢首頁如何實現點擊載入更多
這個屬於瀑布流特效,需要用到js。代碼太長這里粘貼不下,建議你搜「瀑布流特效」「無限載入特效」「點擊載入更多特效」,有現成的例子。
10、求dede 織夢 首頁載入更多代碼
搜搜layui惰性載入,需要操作dede源碼,實現ajax操作