I’ve now started getting back into the swing of things with Zend helpers. They seem to have changed how all this works from how I remember it, so I got to rack my brain a bit to figure this out. I’ll try to make this post as simple as possible. Again, this is for Zend Framework 1.10.
I’m storing my helpers in application/controllers/helpers. The helper I’m writing is called, let’s say, TestHelper. I created a file, TestHelper.php, in that folder. It’s declared as:
class TestHelper extends Zend_Controller_Action_Helper_Abstract
To get it to be included, I had to do the following two things. First, in application.ini, I added:
resources.frontController.actionHelperPaths.TestHelper = APPLICATION_PATH "/controllers/helpers"
Next, in Bootstrap.php, I added:
protected function _initActionHelpers()
{
Zend_Controller_Action_HelperBroker::addPath('application/controllers/helpers', '');
}
Now I’ll be completely honest: I don’t fully get why this works. Based on what I’ve read of other people’s experience, you shouldn’t have to put the line in the Bootstrap and also in application.ini, but I did. Also apparently should be able to call this by saying $this->_helper->functionname(), but I have to do $this->_helper->testHelper->functionname(). A little frustrating, but I guess it’s more clear to see exactly which helper is being referenced when you’re debugging.
I’m going to blame the Zend Framework documentation here, but that’s a story for another day.
Leave a Reply