首页 > 其他 > 详细

zendframework和smarty整合

时间:2014-06-28 12:37:49      阅读:381      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!