就下载了最新的smarty引擎,(目前的版本是smarty3.1.29),但还是提示模板文件找不到,但提示错误的文件变化了,变成了smarty引擎下面的sysplugins/smarty_internal_template.php文件,
错误提示:
:(
Unable to load template file 'Index/index.html'
错误位置
FILE: D:\www\!work4\thinkphp323full_smarty\ThinkPHP\Library\Vendor\Smarty\sysplugins\smarty_internal_template.php LINE: 139
最后在这个文件的第110行左右,把:
$this->template_resource = $template_resource;
修改为:
$this->template_resource = $template_resource; //原来的赋值语句
//加上THEME_PATH,可以啦,2016-06-09
$this->template_resource = THEME_PATH.$template_resource;
这样就可以在thinkphp3.2.3中使用smarty了。
但是,有没有缺陷,还不知道,有没有更好的办法,也还不知道。
另外:
我的config配置如下:
<?php
return array(
'MODULE_ALLOW_LIST' => array('Admin', 'Home'),//设置只能访问的模块
'DEFAULT_MODULE' => 'Home', //默认访问模块,可以不出现在URL
'APP_USE_NAMESPACE' => true, //应用类库是否使用命名空间 3.2.1新增
'URL_CASE_INSENSITIVE' =>false, //区分大小写
'URL_MODEL' => 2, //使用rewrite模式
'DEFAULT_THEME' => 'default', //默认模板目录
'TMPL_DETECT_THEME_' => true, //自动侦测模板主题
'TMPL_ENGINE_TYPE' => 'Smarty',
'TMPL_ENGINE_CONFIG' => array(
'caching'=>true,
'template_dir' => TMPL_PATH,
'compile_dir' => CACHE_PATH,
'cache_dir' => TEMP_PATH,
'left_delimiter' => '{',
'right_delimiter' => '}',
),
);
.htaccess文件如下:
<IfModule mod_rewrite.c>
Options +FollowSymli
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond $1 !^(DATA|images|otherThings)
##RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
App/Home/IndexController.class.php文件如下:
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
//$this->show('<st
$a = 'abc';
$this->assign('a', $a);
$arr = array('php', 'ja
$this->assign('arr', $arr);
$this->display();
}
}
模板文件:
App/Home/View/default/Index/index.html
内容如下:
<!doctype html>
<html>
<head>
<me
</head>
<body>
<p>
使用了。变量a: {$a}
</p>
<p>
使用smarty的foreach
<ul>
{foreach from=$arr item=list}
<li>{$list}</li>
{/foreach}
</ul>
</p>
</body>
</html>
原文地址:http://qp500.cn/groupby/Blog/16686
1.jpg
( 185.6 KB 下载:1 次 )
最佳答案