cakePHP:当出现错误时我需要包含一个助手
我制作了一个名为“导航”的帮助程序类,该类在每个页面上都会使用,因为它对我的主导航菜单起作用。因此,为了使其正常工作,我在页面控制器中包含了帮助程序,如下所示:
var $helpers = array('Html', 'Javascript', 'Navigation');
但是,当出现诸如缺少视图或找不到帮助程序之类的错误时,我会收到对非对象错误的引用,该错误会扰乱我的页面布局。我猜这是因为错误页面使用了不同的控制器,但是控制器文件中没有文件 error_controller.php 或任何内容。所以我的问题是我需要在哪里声明帮助程序,以便可以通过错误页面找到它。我是否需要制作一个错误控制器文件,或者是否已经有一个可以将其添加到的文件?
任何帮助将不胜感激
谢谢
I have made a helper class called Navigation that gets used on every page because it does stuff to my main navigation menu. So in order for this to work I have included the helper in my pages controller like so:
var $helpers = array('Html', 'Javascript', 'Navigation');
however when there is an error like a missing view or something the helper can't be found and I get a reference to a non-object error that messes my page layout up. I'm guessing this is becuase an error page uses a different controller, however there isn't a file error_controller.php or anything in the controllers file. So my question is where do I need to declare the helper so it can be found by an error page. Would I need to make an error controller file or is there already a file that I can add it in to?
Any help would be much appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它在每个页面上使用,为什么不将其添加到
AppController
?If it's used on every page, why not add it to the
AppController
?