views:

1087

answers:

4

hi all, i am writing an action helper and i need to call another action helper from within that helper. but i dont know how. here in the sample code:

class Common_Controller_Action_Helper_SAMPLE extends Zend_Controller_Action_Helper_Abstract
{
    protected $_view;
    public function __construct(Zend_View_Interface $view = null, array $options = array())
    {
     $this->_view = $view;
    }

    public function preDispatch()
    {
        $flashMessenger = $this->_helper->FlashMessenger; // IT IS NULL
    }
}
+4  A: 

Use the action helper broker:

$flashMessenger =
    Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
mercator
it worked great. :)
rahim asgari
A: 

now i want to pass a varibale from within this helper to the veiw. ($this->view = 'something') how can i do that?

rahim asgari
Following your own code: $this->_view->variable = 'something'; That then becomes available in the view as $this->variable...
mercator
A: 

You can also use getActionController to get a reference back to the actioncontroller you were using for any methods you'd normally use there.

Justin
A: 

Hi!! you can call it in that way

$this->_actionController->OtherActionHelper();

the "_actionController" property references the actual action controller

Bye

Max