DedeCMS教程:在列表页输出当前页码相关信息

softyun3年前cms教程55

本方法原理上适用于DedeV5.3及以上所有的版本,不分编码。

这个问题来源于刚才有一位朋友的需求,他希望在列表页可以自由的调用当前栏目的一些与页码相关的信息。这个需求如果用自带的织梦标签,是无法实现的,我们需要修改源代码后才可实现。

实现步骤

代码修改

打开/include/arc.listview.class.php 文件,找到: 

if(preg_match('/index/i', $listitem)) $plist .= $indexpage; 
if(preg_match('/pre/i', $listitem)) $plist .= $prepage; 
if(preg_match('/pageno/i', $listitem)) $plist .= $listdd; 
if(preg_match('/next/i', $listitem)) $plist .= $nextpage; 
if(preg_match('/end/i', $listitem)) $plist .= $endpage; 
if(preg_match('/option/i', $listitem)) $plist .= $optionlist; 
if(preg_match('/info/i', $listitem)) $plist .= $maininfo; 

这样的代码,一共有两处 静态分页函数与动态分页函数,修改为:

//页码信息相关输出 By 织梦教程网 华强℡ QQ:3421209 
$PageNo = $this->PageNo; 
$TotalResult = $this->TotalResult; 
$TotalPage = $totalpage; 
$PageSize = $this->PageSize; 
if(preg_match('/thisPage/i', $listitem)) $plist .= $PageNo; 
if(preg_match('/TotalResult/i', $listitem)) $plist .= $TotalResult; 
if(preg_match('/TotalPage/i', $listitem)) $plist .= $TotalPage; 
if(preg_match('/PageSize/i', $listitem)) $plist .= $PageSize; 
 
if(preg_match('/index/i', $listitem)) $plist .= $indexpage; 
if(preg_match('/pre/i', $listitem)) $plist .= $prepage; 
if(preg_match('/pageno/i', $listitem)) $plist .= $listdd; 
if(preg_match('/next/i', $listitem)) $plist .= $nextpage; 
if(preg_match('/end/i', $listitem)) $plist .= $endpage; 
if(preg_match('/option/i', $listitem)) $plist .= $optionlist; 
if(preg_match('/info/i', $listitem)) $plist .= $maininfo; 

保存后即可。

注:要修改两处,一个是静态的,一个是动态的,你可以用相关编辑软件的搜索功能进行查找。

前台调用

接下来我们就可以在我们所需要的前台页面 模板文件名一般为 list_***.htm进行调用了,调用的代码一共有如下几个:

文档总数:{dede:pagelist listitem="TotalResult"/} 
分页总数:{dede:pagelist listitem="TotalPage"/} 
分页大小:{dede:pagelist listitem="PageSize"/} 
当前页码:{dede:pagelist listitem="thisPage"/} 

它可以实现在列表页模板中任意地方的调用,也可以同时在多个地方进行调用。

效果预览

接下来,我们来看一下前台的效果预览吧

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

织梦dedecms增加英文栏目名称

在做外贸SEO优化的时候,有时候因为网站功能需求,经常会用到中文站和英文站。这里有一个栏目添加英文名称的方法,下面和大家分享一下。1.数据库新增加字段 typenameen       这里说的字段不...

DedeCms 更新搜索表内容链接(解决搜索路径错误)

dedecmsV5更新搜索表并更新生成页面程序(解决搜索路径错误)点击下载此文件注意:该程序在要您的管理目录才能正常运行 默认目录:dede...

DedeCms教程:windows server 2003 php 环境搭建

windows server 2003是目前国内比较主流的服务器操作系统,其搭建php的环境也是多种多样,其中IIS+Fastcgi+php+mysql安装时最简单的。   1.安装IIS I...

DEDECMS时间格式汇总

1.时间格式{dede:field name='pubdate' function='strftime("%Y年%m月%d日 %H:%M:%S","@me")' /}2007年1月1日 18:30:0...

dedecms 2007 默认幻灯片显示标题

var focus_width=280;var focus_height=220;var text_height=0;  给文字设置一个高度就可以了 一般设置为var text_height=20;...

dede网站内容页如何调取栏目页标题和seo标题

dede网站内容页如何调取栏目页标题和seo标题 内容页调用SEO标题:在之间加入以下代码: {dede:field name='typeid' runphp='yes'}  $id=@me;  gl...