I want to pass a series of variables to my layout.phtml throughout the whole application(globally). And by that I mean I don\'t wanna use
$this->layout()-
In your Application/Module.php 1) Create an Dispatch event for zend framework like this:
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$eventManager->attach('dispatch', array($this, 'loadConfiguration' ));
}
public function loadConfiguration(MvcEvent $e)
{
$controller = $e->getTarget();
$controller->layout()->YOUR_VARIABLE_NAME = $YOUR_VALUE;
}
2) Now You can access your defined variable in your layout like this: $this->YOUR_VARIABLE_NAME;