我用ZF框整合smarty,出了点错误,请各位帮忙看下了。
我用ZF框整合smarty,出了点错误,请各位帮忙看下了,貌似是路径的错误。
我先是在分别创建了application/views/templates和application/views/templates_c和application/views/templates_c/cache_c文件夹。
然后以插件形式。在index.php中加载Smarty。
<?php
/*
* Date: 2009.8.16
* Author:DaGui
* Email:daguizhang@gmail.com
* QQ:308713166
*/
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Asia/Shanghai');
define('WEB_ROOT', 'http://192.168.12.190:81/vote/');
set_include_path('.' .PATH_SEPARATOR .'./library'.PATH_SEPARATOR.'./application/models/'.PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();//设置Zend Framework 自动载入类文件
$registry = Zend_Registry::getInstance();
//配置数据库参数,并连接数据库
$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
Zend_Registry::set('config',$config);
$dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
$dbAdapter->query('SET NAMES UTF8');
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter',$dbAdapter);
//对smarty模版进行初始化
include 'Smarty/Smarty.class.php';
$views = new Smarty();
$views->left_delimiter = "{{";
$views->right_delimiter = "}}";
$views->compile_dir = 'application/views/templates_c';
$views->cache_dir = 'application/views/templates_c/cache_c';
$views->template_dir = 'application/views/templates';
function smarty_block_dynamic($param,$content,&$views)
{
return $content;
}
$views->register_block('dynamic','smarty_block_dynamic',false);
Zend_Registry::set('views', $views);
//创建验证对象 &