I have created an actionHelper with a preDispatch function. I want this preDispatch to send some data to my view. Any idea how I can achieve this?
Asked
Active
Viewed 1,208 times
3 Answers
4
Alternatively (from within your action helper):
$view = $this->getActionController()->view;
$view->myKey = 'myValue';
An action helper is one of the few places in a ZF app that has direct access to the controller instance (as opposed to the controller name, which is accessible in lots of ways in various places).

David Weinraub
- 14,144
- 4
- 42
- 64
-
It says undefined method getActionController() – Abdul Basit Jul 07 '15 at 07:42
-
@AbdulBasit Are you sure you are making this call from within your action-helper that extends `Zend_Controller_Action_Helper_Abstract`? The method is there, certainly [since 1.12.0](https://github.com/zendframework/zf1/blob/release-1.12.0/library/Zend/Controller/Action/Helper/Abstract.php#L68) – David Weinraub Jul 07 '15 at 08:41
1
hey this would be as easy as this :)
$view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view;
$view->your_param = $your_value ;
then you could access it as usually

tawfekov
- 5,084
- 3
- 28
- 51