dedecms sql 分页(sqlser分页)

在当今信息爆炸的时代,网站内容更新速度越来越快,如何高效地展示这些内容,让用户能够快速找到自己感兴趣的信息,成为了网站建设的重要课题。DedeCMS作为一款功能强大的内容管理系统,其SQL分页功能在实现内容展示方面具有显著优势。本文将深入解析DedeCMS SQL分页技巧,帮助您高效实现内容展示。

一、DedeCMS SQL分页原理

在介绍DedeCMS SQL分页技巧之前,我们先来了解一下其原理。DedeCMS采用MVC(模型-视图-控制器)架构,其中模型层负责数据操作,视图层负责展示数据,控制器层负责处理用户请求。在分页功能中,模型层负责从数据库中查询指定页面的数据,视图层负责展示数据,控制器层负责处理分页请求。

DedeCMS SQL分页主要依靠以下几个关键步骤实现:

1. 计算总页数:根据查询条件计算数据库中符合条件的总记录数,然后根据每页显示的记录数计算总页数。

2. 生成分页链接:根据总页数和当前页码生成分页链接,方便用户切换页面。

3. 查询指定页面的数据:根据当前页码和每页显示的记录数,从数据库中查询指定页面的数据。

二、DedeCMS SQL分页技巧

1. 使用DedeCMS内置函数实现分页

DedeCMS内置了多个分页函数,如`dsql->dsqlLimit()`、`dsql->PageSelect()`等,可以直接在模板中调用,实现快速分页。

示例

“`php

// 设置每页显示的记录数

$pageSize = 10;

// 获取当前页码

$page = (isset($page) && $page > 0) ? $page : 1;

// 计算起始记录数

$offset = ($page – 1) * $pageSize;

// 查询指定页面的数据

$dsql->SetQuery(“

dedecms5.7伪静态怎么设置

dede5.7伪静态设置方法。

dede5.7伪静态设置七步法:

第一步、后台-系统参数-核心设置-是否使用伪静态:选择“是”;

注:你的网站空间是否支持伪静态,你可以与空间的IDC商联系一下,如果是自己的服务器,那就更好办了,自己动手,丰衣足食。一般来说,空间都是支持伪静

态的。Apache服务器伪静态相对简单,直接在.htaccess文件中加入相应伪静态规则即可;而IIS服务器伪静态的实现,则需要加载

Rewrite组件,然后配置httpd.ini文件。

第二步、如果你的网站已经存在生成的静态栏目或文章HTML,那么只需在后台-系统-SQL命令行工具中执行如下语句:

将所有文档设置为“仅动态浏览”:

update dede_archives set ismake=-1

将所有栏目设置为“使用动态页”:

update dede_arctype set isdefault=-1

第三步、列表页、文章页伪静态修改

打开/include/helpers/channelunit.helper.php。

(1)查找:

//动态文章

if($cfg_rewrite=='Y')

{

return$GLOBALS[“cfg_plus_dir”].”/view-“.$aid.'-1.html';

}

替换为

//动态文章

if($cfg_rewrite=='Y')

{

return”/DedeCMS/DedeCMS5.7-“.$aid.'-1.html';

}

意思是:将默认的/plus/view-1-1.html文章链接格式改为/DedeCMS/DedeCMS5.7-1-1.html。

(2)查找:

//动态

$reurl=$GLOBALS['cfg_phpurl'].”/list.php?tid=”.$typeid;

替换为

//动态

$reurl=”/category/list-“.$typeid.”.html”;

意思是:将默认的频道或是列表页URL/plus//list.php?tid=1变更为/dedecms/list-1.html形式。

第四步、列表分页伪静态修改

打开/include/arc.listview.class.php

查找:

$plist= str_replace('.php?tid=','-',$plist);

替换为

$plist= str_replace('plus/list.php?tid=',‘DedeCMS/DedeCMS5.7-',$plist);

将默认的plus/list.php?tid=替换成RMB/list-;

意思是:将默认的列表分页链接格式plus/list.php?tid=x$x$xl修改为DedeCMS/DedeCMS5.7-x-x-x.html。

第五步、文章分页伪静态

打开/include/arc.archives.class.php,找到获取动态的分页列表GetPagebreakDM()函数末尾处:

查找:

$PageList= str_replace(“plus/view.php?tid=”,”DedeCMS/DedeCMS5.7-“,$PageList);

替换为

$plist= str_replace('plus/view.php?tid=',’DedeCMS/DedeCMS5.7-',$plist);

将默认的plus/view.php?tid=替换成RMB/huilv-;

意思是:将默认的文章分页链接格式plus/view.php?tid=x$x$xl修改为DedeCMS/DedeCMS5.7-x-x-x.html

第六步、TAG标签伪静态

DedeCms默认的TAG标签URL,形如/tags.php?/dedecms模板/,是不是觉得有个问号不怎么爽,我们改成/tags/dedecms模板/,是不是好看多了。

下面我们来改一下,打开/include/taglib/tag.lib.php:

查找:

$row['link']=$cfg_cmsurl.”/tags.php?/”.urlencode($row['keyword']).”/”;

替换为

$row['link']=$cfg_cmsurl.”/tags/”.urlencode($row['keyword']).”/”;

这样就修改好了,上传你到你的网站,切记:要记得将原网站备份哦!!

第七步、httpd.ini伪静态规则:

[ISAPI_Rewrite]

# 3600= 1 hour

CacheClockRate 3600

RepeatLimit 32

RewriteRule ^(.*)/RMB/list-([0-9]+)\.html$1/plus/list\.php\?tid=$2 [I]

RewriteRule ^(.*)/RMB/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4 [I]

RewriteRule ^(.*)/RMB/huilv-([0-9]+)-([0-9]+)\.html$1/plus/view\.php\?arcID=$2&pageno=$3 [I]

RewriteRule ^(.*)/(.*)_(.*)_([0-9]+)\.html$1/huilv/?from=$2&to=$3&num=$4 [I]

RewriteRule ^(.*)/tags\.html$1/tags\.php [I]

RewriteRule ^(.*)/tags/(.*)(?:(\?.*))*$1/tags\.php\?\/$2 [I]

RewriteRule ^(.*)/tags/(.*)\/(?:(\?.*))*$1/tags\.php\?\/$2\/ [I]

RewriteRule ^(.*)/tags/(.*)\/([0-9])(?:(\?.*))*$1/tags\.php\?\/$2\/$3 [I]

RewriteRule ^(.*)/tags/(.*)\/([0-9])\/(?:(\?.*))*$1/tags\.php\?\/$2\/$3\/ [I]

将上面代码保存为:httpd.ini上传到网站的根目录。

如无特特殊需求建议采用官方默认的生成静态的页面方式浏览。

dedecms 列表点击加载更多读取数据库内容怎么实现

使用方法:

1、加载是用AJAX,需要先引用jQuery

2、模板在arcajax.php第二十八行请自行按需修改

3、arcajax.php放到plus目录下

HTML和js代码:

<divid=”loading27″>加载中</div>

<ahref=”javascript:;”id=”getMore”pnum=”2″class=”index-morebgwmt15″>浏览更多案例……</a>

<scripttype=”text/javascript”>

$(“#getMore”).click(function(){

var_this=$(this),

pnum=_this.attr(“pnum”),//分页码

typeid=1;//栏目ID

if(pnum==0){

returnfalse;

}

$(“#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();

}

})

returnfalse;

})

</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(“RequestError!”);

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:globalname=”autoindex”runphp=”yes”]if(@me%3==0)@me=\'class=”mrnone”\';else@me=””;[/field:global]>

<div><ahref=”[field:arcurl/]”title=”[field:title/]”><imgsrc=”[field:litpic/]”width=”278″height=”245″></a></div>

<h3><ahref=”[field:arcurl/]”title=”[field:title/]”>[field:title/]</a></h3>

<p>[field:descriptionfunction=”cn_substr(@me,150)”/]</p>

<spanclass=”more”><ahref=”[field:arcurl/]”>浏览案例</a></span>

</li>';//模板

//处理列表内容项

$query=”SELECTarc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,

tp.moresite,tp.siteurl,tp.sitepathFROM`#@__archives`arcLEFTJOIN`#@__arctype`tpONarc.typeid=tp.id

WHEREarc.typeidIN(“.GetSonIds($typeid).”)ORDERBYarc.sortrankdesc$limitsql”;

$dsql->SetQuery($query);

$dsql->Execute('al');

$dtp2=newDedeTagParse();

$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']=”<ahref='”.$row['typeurl'].”'>”.$row['typename'].”</a>”;

$row['image']=”<imgsrc='”.$row['picname'].”'border='0'width='$imgwidth'height='$imgheight'alt='”.preg_replace(“#['><]#”,””,$row['title']).”'>”;

$row['imglink']=”<ahref='”.$row['filename'].”'>”.$row['image'].”</a>”;

$row['fulltitle']=$row['title'];

$row['title']=cn_substr($row['title'],$titlelen);

if($row['color']!='')$row['title']=”<fontcolor='”.$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']=”<ahref='”.$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->CTagsas$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().”

“;

}//ifhasRow

else{

$artlist.='';

}

}//LoopCol

}//loopline

$dsql->FreeResult(“al”);

}else

{

die(“RequestError!”);

}

AjaxHead();

echo$artlist;

exit();

dede怎么实现伪静态呢dedecms伪静态

如何将dedecms改为伪静态页面?

设置DEDE5.7伪静态的七步法:

第一步:后台-系统参数-核心设置-使用伪静态:选择是;

注:无论您的网站空是否支持伪静态,您都可以在空中联系IDC提供商。如果是自己的服务器,处理起来会比较容易。自己动手,丰衣足食。一般来说,空支持伪静态。Apache服务器伪静态相对简单,只需在。htaccess文件;要实现IIS服务器的伪静态,需要加载重写组件,然后配置httpd.ini文件。

第二步。如果生成的静态列或文章HTML已经存在于您的网站中,那么只需在后台-系统-SQL命令行工具中执行以下语句:

将所有文档设置为“仅动态浏览”:

updatedede_archivessetismake=-1将所有栏设置为“使用动态页面”:

updatedede_arctypesetisdefault=-1第三步,列表页,文章页伪静态修改。

打开/include/helpers/channelunit.helper.PHP

(1)查找:

if($cfg_rewrite==Y)

{

return$GLOBALS[cfg_plus_dir.$援助。-1.html;

}替换为

if($cfg_rewrite==Y)

{

return.$援助。-1.html;

}含义:将默认的/plus/view-1-1.html文章链接格式改为//DedeCMS/DedeCMS5.7-1-1.html1-1.html。

(2)查找:

$reurl=$GLOBALS[cfg_phpurl]./list.php?tid=.$typeid;替换为:

$reurl=/category/list-.$typeid..html;会默认频道或列表页面URL/plus//list.php吗?Tid=1更改为/dedecms/list-1.html形式。

步骤4:列表分页的伪静态修改。

打开/include/arc.listview.class.PHP。

查找:

$plist=str_replace(.php?tid=,-,$plist);用?替换

$plist=str_replace(plus/list.php?tid=,‘DedeCMS/DedeCMS5.7-,$plist);设置默认的plus/list.php?Tid=替换为人民币/列表-;

会默认列表分页链接格式plus/list.php吗?Tid=x$x$xl修改为DedeCMS/DedeCMS5.7-x-x-x.htmlx-x-x.html。

第五步,文章分页伪静态。

打开/include/arc.archives.class.PHP,找到GetPagebreakDM()函数的结尾,得到动态分页列表:

查找:

$PageList=str_replace(plus/view.php?tid=,DedeCMS/DedeCMS5.7-,$PageList);用?替换

$plist=str_replace(plus/view.php?tid=,’DedeCMS/DedeCMS5.7-,$plist);会默认plus/view.php吗?Tid=换成人民币/吕慧-;

含义:链接默认文章分页格式plus/view.php?Tid=x$x$xl修改为DedeCMS/DedeCMS5.7-x-x-x.htmlx-x-x.html。

步骤6:标记伪静态

DedeCms默认标签tagURL,比如/tags.php?/dedecmstemplate/,你不觉得有个问号太酷了吗?我们改成/tags/dedecmstemplate/,不是好很多吗?

我们改一下,打开/include/taglib/tag.lib.php:

查找:

$row[link]=$cfg_cmsurl./tags.php?/.urlencode($row[keyword])./;用?替换

$row[link]=$cfg_cmsurl./tags/.urlencode($row[keyword])./;所以修改一下,上传到你的网站,记得备份原网站!!

第七,httpd.ini伪静态规则:

[ISAPI_Rewrite]

#3600=1小时

高速时钟速率3600

重复限制32

重写者^(.*)/RMB/list-([0-9])\。html/plus/list\。php\?tid=[I]

重写者^(.*)/RMB/list-([0-9])-([0-9])-([0-9])\。html/plus/list\。php\?tid=$2&ampTotalResult=$3&ampPageNo=[I]

重写者^(.*)/人民币/吕慧-([0-9])-([0-9])\。html/plus/view\php\?arcID=$2&amppageno=[I]

重写者^(.*)/(.*)_(.*)_([0-9])\.html$1/吕慧/?from=$2&ampto=$3&ampnum=[I]

重写者^(.*)/tags\。html/tags\。php[I]

重写者^(.*)/tags/(。*)(?:(\?.*))*/tags\。php\?\/[I]

重写者^(.*)/tags/(。*)\/(?:(\?.*))*/tags\。php\?\/\/[I]

重写者^(.*)/tags/(。*)\/([0-9])(?:(\?.*))*/tags\。php\?\/\/[I]

重写者^(.*)/tags/(。*)\/([0-9])\/(?:(\?.*))*/tags\。php\?\/\/\/[I]将上述代码另存为:httpd.ini,上传到网站根目录。

如果没有特殊需求,建议按官方默认的静态页面生成方式浏览。

织梦网站伪静态是用apche还是nginx好呢?

Apache资格更老一些,比Nginx出来的早,在处理程序方面,Apache我个人认为更好一些!伪静态的作用是优化收录更好,浏览更人性化,例如伪静态的URL还可以被记住,动态的url根本没法记住!当然我说的是很少的一部分。

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享