문제

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?

도움이 되었습니까?

해결책

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).

다른 팁

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

$view = Zend_Layout::getMvcInstance()->getView();
$view->yourVar = 'test';
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top