1
votes

I have a custom controller action helper that I would like to be able to call from a view script. How can I achieve this?

Solution:

Warning: You probably don't really want to call an action helper from your view script unless you aren't using any dispatch hooks. But if you really, really want to call your action helper:

$helper = Zend_Controller_Action_HelperBroker::getStaticHelper('Myhelper');
1

1 Answers

3
votes

Afaik, you can't, and you should not that's MVC. Trying to solve such problem should be a potential warning on your design.

However, in some case you may need to achieve a similar thing.

For example, the flashMessenger() action helper aims to provide a simple way to share messages between requests, however it is not available in the view, you need to manually pass it to the view. I've myself written a wrapper to be able to use as a view helper.

So maybe try to be more explicit on what you're trying to achieve, and we may help you to know if there isn't a good alternative.