【问题标题】:Bypass default view, Kohana绕过默认视图,Kohana
【发布时间】:2011-04-18 17:10:15
【问题描述】:

我想返回一个视图,但是 Kohana 强制它通过默认视图,这是我不想要的。如何临时禁用默认视图?

【问题讨论】:

  • 什么是“默认视图”?你说的是模板控制器吗?

标签: php model-view-controller kohana


【解决方案1】:

作为 zombor cmets,如果你真的在谈论模板控制器,你可以通过在你的控制器中加入这一行来禁用它的渲染:

$this->auto_render = FALSE;

【讨论】:

    【解决方案2】:
     public function action_index()
        {
            $user_view = $this->getUserView();
    
            $this->request->response = View::factory('templates/main',$user_view);
        }
    public function getUserView($user_details)
        {
            $user_view['list_page'] = View::factory('templates/usermgt')
                            ->bind('user_detail','data')
                            ->bind('msg','test');
            return $user_view;
        }
    

    其中 getUserView() 将视图页面返回到操作索引。 希望符合你的要求

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-19
      • 1970-01-01
      • 2021-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-23
      • 1970-01-01
      相关资源
      最近更新 更多