• dedecms模板明明存在,还是报错:说模板不存在


    各种错误的可能

    1.我的模板现在是htm结尾。没有错
    2.我的模板中,存在这个文件,而且动态预览的时候,都是正常的。
    但为什么还是,模板文件不存在,无法解析文档!

    关于我自己的,文章更新模板不存在的方法

    WWWW/include/arc.archives.class.php文件
    关于文章的模板不存在找到这个函数,我是把其中的_m注释掉了。不知道为什么,现在加载的都是_m的手机模板

       /**
         *  载入模板
         *
         * @access    public
         * @return    void
         */
        function LoadTemplet($m=0)
        {
    		if($m){
    			$pathinfo = pathinfo($this->GetTempletFile());
    			// $tempfile = $pathinfo[dirname].'/'.basename($pathinfo[basename],'.htm').'_m.htm';	
    			 $tempfile = $pathinfo[dirname].'/'.basename($pathinfo[basename],'.htm').'.htm';	
                if(!file_exists($tempfile) || !is_file($tempfile))
                {
                    echo "文档ID:{$this->Fields['id']} - {$this->TypeLink->TypeInfos['typename']} - {$this->Fields['title']}<br />";
                    // echo "模板文件不存在,无法解析文档!";
                    echo $this->TypeLink->TypeInfos["temparticle"]."模板文件不存在,无法解析文档!".$m;
                    exit();
                }
                $this->dtp->LoadTemplate($tempfile);
                $this->TempSource = $this->dtp->SourceString;
    		}else{
    			if($this->TempSource=='')
    			{
    				$tempfile = $this->GetTempletFile();
    				if(!file_exists($tempfile) || !is_file($tempfile))
    				{
    					echo "文档ID:{$this->Fields['id']} - {$this->TypeLink->TypeInfos['typename']} - {$this->Fields['title']}<br />";
    					echo "模板文件不存在,无法解析文档!";
    					exit();
    				}
    				$this->dtp->LoadTemplate($tempfile);
    				$this->TempSource = $this->dtp->SourceString;
    			}
    			else
    			{
    				$this->dtp->LoadSource($this->TempSource);
    			}
    		}
        }
    
    

    关于栏目模板不存在的解决方法

    关于栏目的设置,就算是封面栏目,只用到封面的模板,列表的模板如果错了。也会报错。
    所以,这里的设置中,所有的模板,都要存在才行

    为什么呢?因为在includearc.listview.class.php文件中,会初始化模板,好像会统计所有的模板吧

    //初始化列表模板,并统计页面总数
            $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','.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','.htm',$tempfile);
                }
            }
            
            if(!file_exists($tempfile)||!is_file($tempfile))
            {
                echo "模板文件不存在,无法解析文档!$tempfile";
                exit();
            }
    
  • 相关阅读:
    python 中多个装饰器的执行顺序:
    Python基础思维导图
    怎样写出靠谱的RESUTful API接口?
    python中yield()的用法详解
    Flask思维导图
    Django的设计模式
    MySQL
    MySQL
    Linux
    zsh oh-my-zsh 插件推荐
  • 原文地址:https://www.cnblogs.com/cn-oldboy/p/13852432.html
Copyright © 2020-2023  润新知