I'm using dispatcher to dispatch custom controller, action, and view:
$Controller = 'contact';
$Action = 'index';
$this->getDI()->get('dispatcher')->setControllerName($Controller);
$this->getDI()->get('dispatcher')->setActionName($Action);
$this->getDI()->get('dispatcher')->dispatch();
$ViewController = $this->getDI()->get('dispatcher')->getControllerName();
$ViewAction = $this->getDI()->get('dispatcher')->getActionName();
$this->getDI()->get('view')->start();
$this->getDI()->get('view')->render($ViewController, $ViewAction, $e);
It is working fine and the controller is being dispatched and view is rendering correctly, but there is one problem in view variables when I set them in the controller:
$this->view->setVar('A', 1);
// or
$this->view->A = 1;
Then in view contact/index.phtml when I try to print $A variable:
echo $A;
I got the following error: Notice: Undefined variable: A in ..XXXXX/app/views/contact/index.phtml on line 1
Any suggestions on how can I assign variables to be used in views. Thank you