仔细观察dedecms的页面构造
来源:爱站网时间:2020-06-18编辑:网友分享
dedecms的页面构造新手可以完成的,但是很多页面都需要进行改进,下文是爱站技术频道小编带给大家的仔细观察dedecms的页面构造,我们一起看看下文的详解吧!
dedecms的页面构造新手可以完成的,但是很多页面都需要进行改进,下文是爱站技术频道小编带给大家的仔细观察dedecms的页面构造,我们一起看看下文的详解吧!
dede的分页如果有两个页码显示的话,无法显示出总的文章数,举个例子:
在普通文章模型下面,列表的分页是这样的:

但是在独立模型中就成了这样了

最后面的共*页*条的信息不见了,相信遇到这个问题的同学首先想到的是自己哪里用错了,其实不是,dede独立模型这里的代码是偷工减料了的。处理独立模型列表的代码在arc.sglistview.class.php中,我们比较下同样负责显示分页的代码段,独立模型和普通模型中有什么区别:
普通文章模型:
/**
* 获取动态的分页列表
*
* @access public
* @param string $list_len 列表宽度
* @param string $list_len 列表样式
* @return string
*/
function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")
{
global $cfg_rewrite;
$prepage = $nextpage = '';
$prepagenum = $this->PageNo-1;
$nextpagenum = $this->PageNo+1;
if($list_len=='' || preg_match("/[^0-9]/", $list_len))
{
$list_len=3;
}
$totalpage = ceil($this->TotalResult/$this->PageSize);
if($totalpageTotalResult>0)
{
return "
|
独立模型:
/**
* 获取动态的分页列表
*
* @access public
* @param int $list_len 列表宽度
* @param string $listitem 列表样式
* @return string
*/
function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")
{
global $nativeplace,$infotype,$keyword;
if(empty($nativeplace)) $nativeplace = 0;
if(empty($infotype)) $infotype = 0;
if(empty($keyword)) $keyword = '';
$prepage = $nextpage = '';
$prepagenum = $this->PageNo - 1;
$nextpagenum = $this->PageNo + 1;
if($list_len=="" || preg_match("/[^0-9]/", $list_len))
{
$list_len=3;
}
$totalpage = ceil($this->TotalResult / $this->PageSize);
if($totalpageTotalResult>0)
{
return "共1页/".$this->TotalResult."条记录";
}
if($this->TotalResult == 0)
{
return "共0页/".$this->TotalResult."条记录";
}
$purl = $this->GetCurUrl();
$geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&";
$hidenform = "\r\n";
$hidenform = "\r\n";
$hidenform = "\r\n";
$hidenform = "\r\n";
$hidenform .= "\r\n";
$purl .= "?".$geturl;
//获得上一页和下一页的链接
if($this->PageNo != 1)
{
$prepage.="
|
仔细观察 普通模型中在28行左右的位置多了句$maininfo = "
而且在最后,普通模型中将$maininfo的值加入了$plist字符串中。(更细节的地方是普通模型还判断了标签中是否有info属性来决定是否加入:
if(preg_match('/info/i', $listitem)) $plist .= $maininfo;
|
)独立模型中这些都省了。
要将独立模型修改过来很简单,不过“普通模型还判断了标签中是否有info属性来决定是否加入”这点我就不去实现了,这里不判断直接再任何情况下都加入maininfo:
/**
* 获取动态的分页列表
*
* @access public
* @param int $list_len 列表宽度
* @param string $listitem 列表样式
* @return string
*/
function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")
{
global $nativeplace,$infotype,$keyword;
if(empty($nativeplace)) $nativeplace = 0;
if(empty($infotype)) $infotype = 0;
if(empty($keyword)) $keyword = '';
$prepage = $nextpage = '';
$prepagenum = $this->PageNo - 1;
$nextpagenum = $this->PageNo + 1;
if($list_len=="" || preg_match("/[^0-9]/", $list_len))
{
$list_len=3;
}
$totalpage = ceil($this->TotalResult / $this->PageSize);
if($totalpageTotalResult>0)
{
return "共1页/".$this->TotalResult."条记录";
}
if($this->TotalResult == 0)
{
return "共0页/".$this->TotalResult."条记录";
}
$maininfo = "
|
以上内容就是爱站技术频道小编分享的仔细观察dedecms的页面构造,详细看完的朋友一定都有所了解,为了帮助更多朋友,我们还整理了更加齐全的知识。
