CakePHP 2.0.3 对象上的致命错误 flash()

发布于 2024-12-16 22:18:12 字数 345 浏览 1 评论 0原文

当我尝试使用错误的控制器时,我收到此消息,并且我发现我没有从 cakephp 中得到正确的错误,我在 2.0.0 中得到了正确的错误:

现在,当我尝试使用错误的控制器时,我仅收到此消息:

Fatal error: Call to a member function Flash() on a non-object in
/srv/www/htdocs/web843/HTML/schaetzmal/lib/Cake/View/Layouts/default.ctp
on line 44

cakephp 2.0.3 是否有错误,或者我是否错过了要安装的东西来让这个工作或我可以做的其他事情?

I've get this message when I tried to use a wrong controller and I figured it out that I'm not getting the right Error from cakephp I've got in 2.0.0 the right one:

Now when I try a wrong controller I get only this message:

Fatal error: Call to a member function Flash() on a non-object in
/srv/www/htdocs/web843/HTML/schaetzmal/lib/Cake/View/Layouts/default.ctp
on line 44

Does cakephp 2.0.3 have an bug or do I miss something to install to let work this or something else what I can do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吾家有女初长成 2024-12-23 22:18:12

确保您已将会话助手添加到公共 $helpers 数组中。

class SomethingsController extends AppController {
    public $helpers = array('Session');
}

或者您可以将其添加到全局AppController,以便会话助手可供所有控制器使用。

class AppController extends Controller {
    public $helpers = array('Session');
}

Make sure you've added the Session helper to your public $helpers array.

class SomethingsController extends AppController {
    public $helpers = array('Session');
}

Or you could add it to a global AppController so that the Session helper is available to all controllers.

class AppController extends Controller {
    public $helpers = array('Session');
}
悲凉≈ 2024-12-23 22:18:12

我发现了一些问题,为什么我的 AppController 无法工作。

就像mensch说的那样,我必须在我的AppController中使用Session来实现全局,但这不是解决方案,因为cakephp的书在“全局 AppController"

注意
CakePHP 将以下变量从 AppController 合并到应用程序的控制器:

  • $组件
  • $助手
  • $使用

但它没有发生。因为我在公共变量 $helpers 中覆盖了它。
因此,我采用给定的父级并将其与它合并:

<?

class AppController extends Controller {
    
    public $viewClass   = 'Theme';
    public $theme;
    
    public function beforeFilter() {
        parent::beforeFilter();
        $this->theme = 'SM';
        $this->helpers = array('Form','Html','Js');
    }
    
}

?>

$this->helpers = array('Form','Html','Js'); 进行合并并且工作正常。
谢谢你们,

谢谢你们帮助mensch,这就是我需要的黑客

I found some problems why my AppController didn´t work.

Like mensch says i have to use Session in my AppController for global but that´s not the solution because the book of cakephp says in "a global AppController"

NOTE
CakePHP merges the following variables from the AppController to your application’s controllers:

  • $components
  • $helpers
  • $uses

but it´s not happening. Because i overwrite it in the public variable $helpers.
therfore i take the parent given one and merge it with it:

<?

class AppController extends Controller {
    
    public $viewClass   = 'Theme';
    public $theme;
    
    public function beforeFilter() {
        parent::beforeFilter();
        $this->theme = 'SM';
        $this->helpers = array('Form','Html','Js');
    }
    
}

?>

the $this->helpers = array('Form','Html','Js'); do the merge and it works fine.
thank you guys

thanks for helping mensch that was the hack i needed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文