织梦dedecms列表页实现第一页与其他页调用不同模板的办法

2022-11-19dedecms开发
195

我们想让dedecms织梦第一页与其他第二页、第三页、、、后面的页调用的不同模板,这个要怎么实现呢?

第一步 修改核心文件

打开 /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

第三步 更新生成

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

相关推荐

织梦cms批量删除所有无效TAGS的办法
使用过DedeCMS的站长应当都遇到过这样的问题,在我们删掉一些文章内容后,tags标识中就慢慢拥有许多失效的标识存有,这种TAGS标识并不会跟随大家删掉文章内容一起删掉,如果是受欢迎的词还行,有很多文章内容都是有,如果是小众词,便会发生在TAGS目录有词,...
2023-08-17 dedecms开发
181

怎么修改织梦DEDECMS源码tags标签字数限制
修改织梦DEDECMS中TAG标签字数长度限制的方法共两个步骤,分别是对数据库字数和提交文件的字数进行修改。 一、我们通过织梦DEDECMS后台程序中的系统设置栏目下的SQL命令行工具,来修改数据库中表wmd_tagindex 和wmd_taglist的tag字段属性,将TAG字段属性中...
2023-02-16 dedecms开发
196

织梦dedecms列表页实现第一页与其他页调用不同模板的办法
我们想让dedecms织梦第一页与其他第二页、第三页、、、后面的页调用的不同模板,这个要怎么实现呢? 第一步 修改核心文件 打开 /include/arc.listview.class.php 找到,大概在第330行 $this-ParseDMFields($this-PageNo,1); 在它的上面加入: $tempfile = $GL...
2022-11-19 dedecms开发
195

织梦dedecms调用当前栏目文章数的方法
这篇文章给大家分享的是有关织梦dedecms调用当前栏目文章数的方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。 做模板时,经常需要为每个栏目加上此栏目的文章数。和大家分享下实现的方法,此方法适合5.6及5.7、5.7sp1其它...
2022-11-05 dedecms开发
186

dedecms织梦无需登录注册可下单购买的修改
dedecms织梦无需登录注册可下单购买的修改,首先找到/plus/carbuaction.php文件,找到如下代码: //确认用户登录信息if($cfg_ml-IsLogin()){ $userid = $cfg_ml-M_ID;}else{ $username = trim($username); $password = trim($password); if(empty($username)...
2022-11-02 dedecms开发
171

DEDECMS织梦复制https链接网站图片无法本地化的解决办法
现在许多网站使用了SSL技术,网站采用https链接,我们在复制https链接网站的内容,发现图片无法本地化,那么我们想要将这些图片本地化,要怎么操作呢? 第一步: 找到dede/inc/inc_archives_functions.php (注:前边红色的dede目录是您的后台目录) 定位到...
2022-06-15 dedecms开发
125