QQ在线咨询在线咨询帮做网络积累了丰富的项目经验,聚集了一批资深专业人才,售后服务一流,内业好评不断,是一家专业的网站建设服务商。微信:专业的网站建设服务商。微信:网站建设地图 | 城市分站

织梦栏目列表页实现第一页与其他页调用不同模板文件

时间:2020-01-04 12:24:24作者:网站建设工程师来源:帮做网络浏览量:0

导  读:摘要: 织梦栏目列表页实现第一页的模板与其他第二页、第三页、、、后面的页调用的不...
摘要:织梦栏目列表页实现第一页的模板与其他第二页、第三页、、、后面的页调用的不同模板,分开为2个栏目列表模板,此教程支持栏目页动态、静态、伪静态下使用。

栏目列表页第一页+分页条效果

栏目列表页第二页和其他页

前面有教程讲到栏目列表页第一个文档与其他文档不同教程《织梦栏目列表页第一个文章与其他文章不同样式》

这次教程实现的是第一页的模板与其他第二页、第三页、、、后面的页调用的不同模板,分开为2个栏目列表模板,此教程支持栏目页动态、静态、伪静态下使用。

第一步 修改核心文件

打开 /include/arc.listview.class.php 找到,大概在第330行

$this->ParseDMFields($this->PageNo,1);
  • 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);
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

如图

继续找到,大概在第450行的

$this->ParseTempletsFirst();
  • 1

注意是在第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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

如图

第二步 添加第一页模板文件及命名

第一页模板,在原栏目列表模板后面加_1

例如,原列表模板是 list_dongwu.htm

如果你想让第一页跟list_dongwu.htm不一样的话,你可以建立一个

list_dongwu_1.htm

系统在动态或者生成静态时,栏目列表第一页优先去找这个 _1 的第一页模板文件,存在就输出,不存在就使用默认的原列表模板 list_dongwu.htm

第三步 更新生成

更新系统缓存,静态的生成,动态的直接查看效果


转载请注明出处:网站首页> 知识学堂 > dedecms仿站 > 织梦栏目列表页实现第一页与其他页调用不同模板文件


继续阅读相关文章