Chinaunix

标题: smarty 出现错误 [打印本页]

作者: d_bsky    时间: 2008-04-18 12:09
标题: smarty 出现错误
这个是index.php代码:
<?php
require ('../../libs/Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = "smarty/templates/templates";
$smarty->compile_dir = "smarty/templates/templates_c";
$smarty->config_dir = "smarty/templates/config";
$smarty->cache_dir = "smarty/templates/cache";
$smarty->caching = false;  
$hello = "Hello World!";
$smarty->assign("hello",$hello);  
$smarty->display('index.tpl');

?>

这个是index.tpl的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Smarty</title>
</head>
<body> {$hello} </body>
</html>

但是我运行index.php出错.错误提示是:

Warning: Smarty error: unable to read resource: "index.tpl" in E:\AppServ\www\xinjian\smarty\libs\Smarty.class.php on line 1092


这个是什么意思?我觉得没哪错啊.到底怎么了?我刚接触模板,请高手们指教!!谢谢拉!!!
作者: 银子    时间: 2008-04-18 13:33
检查一下模板路径..

smarty->template_dir = "smarty/templates/templates"; 这样写不正确吧..
作者: d_bsky    时间: 2008-04-18 14:24
感谢楼上的,经过改过之后确实是那里出错了.谢谢啊!!!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2