织梦栏目列表页第一页与其它分页使用不同列表模板,栏目列表页的第一页使用一种像封面式的模板,其他分页的第二页、第三页与后面的分页调用使用的不同模板,分开为2个栏目列表模板,此教程支持栏目页动态、静态、伪静态下使用。效果图如下:
具体实现方法如下:
一、修改list列表文件
- $this->ParseDMFields($this->PageNo,1);
1.打开 /include/arc.listview.class.php 找到,大概在第330行,在它的上面加入以下代码:
- $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist'];
- $tempfile = str_replace("{tid}", $this->TypeID, $tempfile);
- $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
- if ( defined('DEDEMOB') )
- {
- $tempfile =str_replace('.htm','_m.htm',$tempfile);
- }
- if(!file_exists($tempfile))
- {
- $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm";
- if ( defined('DEDEMOB') )
- {
- $tempfile =str_replace('.htm','_m.htm',$tempfile);
- }
- }
- if(!file_exists($tempfile)||!is_file($tempfile))
- {
- echo $this->Fields['typename']." [ID:{$this->TypeID}] ".$GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']."模板文件不存在,无法解析文档!";
- exit();
- }
- if( $this->PageNo===1 )
- {
- $tempfile2 =str_replace('.htm','_1.htm',$tempfile);
- if(file_exists($tempfile2) && is_file($tempfile2))
- {
- $this->dtp->LoadTemplate($tempfile2);
- $this->ParseTempletsFirst();
- }
- }
- else
- {
- $this->dtp->LoadTemplate($tempfile);
- }
2.继续找到,大概在第450行的,注意是在第450行左右的这个代码,因为这个代码有3处,请认准是在大概第450行上这个
- $this->ParseTempletsFirst();
找到后在它的上面加入以下代码:
- $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist'];
- $tempfile = str_replace("{tid}", $this->TypeID, $tempfile);
- $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
- if ( defined('DEDEMOB') )
- {
- $tempfile =str_replace('.htm','_m.htm',$tempfile);
- }
- if(!file_exists($tempfile))
- {
- $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm";
- if ( defined('DEDEMOB') )
- {
- $tempfile =str_replace('.htm','_m.htm',$tempfile);
- }
- }
- if(!file_exists($tempfile)||!is_file($tempfile))
- {
- echo $this->Fields['typename']." [ID:{$this->TypeID}] ".$GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']."模板文件不存在,无法解析文档!";
- exit();
- }
- if( $this->PageNo===1 )
- {
- $tempfile2 =str_replace('.htm','_1.htm',$tempfile);
- if(file_exists($tempfile2) && is_file($tempfile2))
- {
- $this->dtp->LoadTemplate($tempfile2);
- }
- }
- else
- {
- $this->dtp->LoadTemplate($tempfile);
- }
二、增加List模板文件,命名列表模板
1.栏目列表页的第一页第一页模板,在原栏目列表模板后面加_1,例如,原列表模板是 list_article.htm,如果你想让第一页跟list_article.htm不一样的话,你可以建立一个list_article_1.htm
2.系统在动态或者生成静态时,栏目列表第一页优先去找这个 _1 的第一页模板文件,存在就输出,不存在就使用默认的原列表模板 list_article.htm
三、在网站后台更新系统缓存,重新生成相关栏目的静态页,如果使用动态页面的栏目,直接查看效果即可。
继续阅读与本文标签相同的文章:
织梦栏目列表页第一篇文章显示图文其它文章显示标题的实现方法
下一篇让织梦采集模块完全兼容采集https站点的方法与文件下载