开发者

cakePHP: I need to include a helper for when there is an error

开发者 https://www.devze.com 2023-01-21 19:24 出处:网络
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 controll

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 c开发者_JAVA百科an add it in to?

Any help would be much appreciated

Thanks


If it's used on every page, why not add it to the AppController?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号