码迷,mamicode.com
首页 > 其他好文 > 详细

zendframework和smarty整合

时间:2014-06-21 14:13:59      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:class   ext   com   get   文件   art   

一、 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

zendframework和smarty整合

标签:class   ext   com   get   文件   art   

原文地址:http://www.cnblogs.com/jakentec/p/3798831.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!