Reputation: 10306
Is it possible to use a plugin helper in a plugin element in CakePHP 2.x?
My directory looks like this:
/app/Plugin/
MyPlugin/
Controller/
MyController.php
View/
Elements/
mywidget.ctp
Helper/
FooHelper.php
What I want to do is to use the widget mywidget.ctp somewhere in my project. In the widget, there is a requestAction()-call to get data from the controller. This data has to be rendered using some of the methods in FooHelper. Loading it in the controller doesn't help here.
I think, it should be possible to do this by loading FooHelper in my AppController's $helpers array, but I don't want it to be loaded everywhere on the site. Is there some other possiblity? I already found a workaround with ClassRegistry::init(), but this doesn't seem to work with plugins?
Thanks for your help!
Upvotes: 1
Views: 3008
Reputation: 6767
You should be able to load helpers in the view via $this->Helpers->load('MyPlugin.Foo');
in 2.0+ then us it normally via $this->Foo->someMethod();
Upvotes: 5