一、 smarty引用
把这段代码添加到zendframework根目录下的index.php里,
include ‘./library/Smarty/libs/Smarty.class.php‘;
$smarty = new Smarty();
$smarty -> template_dir = "./application/views/scripts/";//设置模板显示路径
$smarty -> compile_dir = "./application/views/scripts/templates_c";
$smarty -> left_delimiter = "<{";
$smarty -> right_delimiter = "}>";
$registry = Zend_Registry::getInstance();
$registry->set(‘smarty‘,$smarty);
二、创建smartycontroller.php文件
class SmartyController extends Zend_Controller_Action
{
function init() {
$this->registry = Zend_Registry::getInstance();
$this->view = $this->registry[‘smarty‘];
$baseurl = $this->_request->getBaseUrl();
$this->view->assign(‘baseurl‘,$baseurl);
}
function indexAction(){
$title = "运行成功了。";
$this->view->assign(‘title‘,$title);
$this->view->display(‘smarty/index.phtml‘);
}
}
三、在/views/scripts/下创建smarty文件夹,在文件夹里创建index.phtml
<p>hello world</p>
<p><{$title}></p>
四、在浏览器里输入localhost/smarty/index;
运行成功了。
zendframework和smarty整合,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/jakentec/p/3798831.html