嘗試yaf框架--持續更新

最近用yaf寫項目,很難過,yaf給我的感覺就好比買房子,有人買毛坯,有人買簡裝,有人買精裝。yaf就是連牆都還沒有的一個框。

這是優點也是缺點,搭架構的過程艱難無比,所幸現在有點體悟。

做個筆記  這些在http://www.laruence.com都有

ajax請求關閉html輸出

 public function init() {
             /**
              * 如果是Ajax請求, 則關閉HTML輸出
              */
             if ($this->getRequest()->isXmlHttpRequest()) {
                 Yaf_Dispatcher::getInstance()->disableView();
             }
         }
public function init() {
             /**
              * 如果不是Ajax請求, 則開啓HTML輸出 默認開啓
              */
             if (!$this->getRequest()->isXmlHttpRequest()) {
                 Yaf_Dispatcher::getInstance()->enableView();
             }
          }
public function init() {
        if ($this->getRequest()->isXmlHttpRequest()) {
            //如果是Ajax請求, 關閉自動渲染, 由我們手工返回Json響應
            Yaf_Dispatcher::getInstance()->autoRender(FALSE);
        }
     }
public funciton init() {
           /**
            * 如果用戶沒登陸, 則轉給登陸動作   //轉移動作
            */
           if($user_not_login) {
              $this->forward("login");
           }
        }
 public funciton init() {
           if($user_not_login)
              $this->redirect("/login/");
        } //重定向

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章