迅雷破解版VIP10不限速下载

张开发 2026-01-06 22:54:53 11次阅读 0次点赞 1次下载 0条评论

tp5里模版引用其它文件时 viewpath 无效,详见如下index.html文件位置 VIEW Dservershtdocsthink0rc2publictmpindexindex.html array 39;name39; gt; 39;thinkphp39;, include filequot;index...

tp5里模版引用其它文件时view_path无效,详见如下:

//index.html

//文件位置:[ VIEW ] D:\servers\htdocs\think-5.0-rc2\public\tmp\index\index.html [ array ( 'name' => 'thinkphp', ) ]

{include file="index@view/index/public/abc/def/g" /}

//文件位置:D:/servers/htdocs/think-5.0-rc2/application/index/view/index/public/abc/def/g.html

//这是可以正常识别

{include file="index/public/abc/def/g" /}

//文件位置:D:/servers/htdocs/think-5.0-rc2/public/tmp/index/public/abc/def/g.html

//这句不能识别,因为template->parseTemplateFile()中的$this->config['view_path']为空引起错误.

//https://github.com/top-think/think/blob/master/thinkphp/library/think/Template.php#L1017

{include file="abc" /}

//这样正常.

...

//index.php

namespace app\index\controller;

class Index

{

public function index()

{

$view = new \think\View([

'view_path' => realpath('./tmp'),

'view_suffix' => '.html',

'view_depr' => DS,

'view_layer' => VIEW_LAYER,

'parse_str' => [],

'engine_type' => 'think',

]);

// 渲染模板输出 并赋值模板变量

return $view->config('view_path','./tmp')->fetch('index', ['name' => 'thinkphp']);

}

}

https://github.com/top-think/think/blob/master/thinkphp/library/think/Template.php#L1017

这里的(defined('THEME_PATH') && substr_count($template, '/') < 2 ? THEME_PATH : $this->config['view_path']);条件我不清楚你们有什么用意但是

$this->config['view_path']

中永远为空.所以返回的路径不是绝对路径.从而导致parseTemplateName不能得到文件内容.

希望能找到**$this->config['view_path']**总为空的原因.

另外最新的git,也同样有这个问题.


张开发 张开发
评论

评论列表 共有 0 条评论

发表评论发布评论后审核成功,即可显示在列表中...

下载地址

云服务器特惠

新用户首购低至3折,高性能云服务器限时优惠

文章 12
粉丝 0
获赞 1
私信

云服务器特惠

新用户首购低至3折,高性能云服务器限时优惠

大家都在看

云服务器特惠

新用户首购低至3折,高性能云服务器限时优惠