不是有这些嘛?你这些是怎么设的。$tpl = new Smarty();
$tpl->template_dir = $g_site_root . "/templates/default/";
$tpl->compile_dir = $g_site_root . "/templates_c/";
$tpl->config_dir = $g_site_root . "/configs/";
$tpl->cache_dir = $g_site_root . "/cache/";
$tpl->cache_lifetime = 0;
$tpl->caching = false;
$tpl->left_delimiter = '{';
$tpl->right_delimiter = '}';
$tpl->template_dir = $g_site_root . "/templates/default/";
$tpl->compile_dir = $g_site_root . "/templates_c/";
$tpl->config_dir = $g_site_root . "/configs/";
$tpl->cache_dir = $g_site_root . "/cache/";
$tpl->cache_lifetime = 0;
$tpl->caching = false;
$tpl->left_delimiter = '{';
$tpl->right_delimiter = '}';
$smarty->compile_dir = '/web/www.example.com/smarty/guestbook/templates_c/';
$smarty->config_dir = '/web/www.example.com/smarty/guestbook/configs/';
$smarty->cache_dir = '/web/www.example.com/smarty/guestbook/cache/';上面四个的值设置成你的旧可以了,可以用相对目录
require_once ("Smarty/Smarty.class.php");
class Tpl extends Smarty {
var $template_file;
function Tpl($title="") {
$this->Smarty();
$this->template_dir = 自己的路径;
$this->compile_dir = 自己的路径;
$this->config_dir = 自己的路径TH;
$this->cache_dir = 自己的路径;
$this->caching = false;
$this->template_file = $title;
}
function show() {
$this->display($this->template_file);
}
}
?>
现在phpwind和discuz采用的模版方式也不错啊。我看比Smarty好!
var $template_dir = '/templates/';
var $compile_dir = '/templates_c/';
var $config_dir = '/configs/';运用的时候我就直接这样写的:
$smarty = new Smarty();
$smarty->display("head.tpl");
放到网站根目录下运行就没事,到其他目录里就出错了。
错误提示:
unable to read resource: "head.tpl" in d:\usr\www\html\libs\Smarty.class.php on line 1095
http://www.code2000.com/html.rar