这篇文章主要为大家详细介绍了织梦模板制作实现栏目列表页第一页与其他页调用不同模板文件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。
前端时间给用户用织梦模板制作一个关于狗狗主题的网站,用户其中有一个要求是实现栏目列表页第一页与其他页调用不同模板文件,即:在页面也显示的第一页和第二页样式布局不一样。如下图所示:
栏目列表页第一页+分页条效果
栏目列表页第二页和其他页显示效果
要实现如上面两张图片的效果,我们需要对织梦系统进行一定的修改和二次开发。因为,如果我们单单只要实现栏目页第一个文章样式与其他文章样式不同效果,我们可以不需要修改织梦的核心文件,不用改动任何程序文件,只需要用标签就能实现,实现代码如下:
{dede:list pagesize='10'} [field:array runphp=yes] ($GLOBALS[autoindex]==1) ? @me="<li><a href='{@me['arcurl']}' class='preview'> <img src='{@me['litpic']}'/></a><a href='{@me['arcurl']}' class='title'>{@me['title']}</a> <span class='info'><small>日期:</small>".GetDateTimeMK(@me['pubdate'])."<small>点击:</small>{@me['click']} <small>好评:</small>{@me['scores']}</span><p class='intro'>简介:{@me['description']}</p></li>":@me="<li><a href='{@me['arcurl']}' class='title'>{@me['title']}</a> <span class='info'><small>日期:</small>".GetDateTimeMK(@me['pubdate'])."<small>点击:</small>{@me['click']}<small>好评:</small>{@me['scores']}</span> <p class='intro'>简介:{@me['description']}</p></li>";[/field:array] {/dede:list}
但是我们现在需要实现的是栏目列表页第一页与其他页调用不同模板文件,而不仅仅是第一个文章样式,而是整个第一个页面的模板和第二页面、第三页……后面页调用的不同模板,分开为2个栏目列表模板。这就不是一些简单的标签就能实现的了,所有我们需要对织梦系统的核心文件进行二次开发,另外这次织梦模板网提供的教程支持栏目页动态、静态、伪静态下使用。
第一步、修改核心文件
打开 /include/arc.listview.class.php 找到,大概在第330行
$this->ParseDMFields($this->PageNo,1);
在它的上面加入
$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); }
如下图所示:
继续找到,大概在第450行的
$this->ParseTempletsFirst();
注意是在第450行左右的这个代码,因为这个代码有3处,请认准是在大概第450行上这个
找到后在它的上面加入
$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); }
如下图所示:
第二步、添加第一页模板文件及命名
第一页模板,在原栏目列表模板后面加_1
例如,原列表模板是 list_dongwu.htm
如果你想让第一页跟list_dongwu.htm不一样的话,你可以建立一个
list_dongwu_1.htm
系统在动态或者生成静态时,栏目列表第一页优先去找这个 _1 的第一页模板文件,存在就输出,不存在就使用默认的原列表模板 list_dongwu.htm
第三步、更新生成
更新系统缓存,静态的生成后查看效果,动态的可以直接查看效果
以上就是织梦模板制作实现栏目列表页第一页与其他页调用不同模板文件的全部内容,希望对大家的学习和解决疑问有所帮助,也希望大家多多支持网。
织梦会员系统BUG会员动态管理和前台会员中心会员动态管理不显示BUG修复
我们先通过下面的截图看下我们普通的织梦会员中心和织梦后台会员管理中存在的BUG。 上图所示,这个本来是织梦的会员动态,默认是会对会员的【添加文档】【添加好友】【评论】【