Reputation: 6408
I am trying to use the Zend Framework and I am having trouble figuring out how to pass information from the controller to the view.
It looks like I should be creating an instance of Zend_View, but when I call the render function I can't seem to get it to load the correct view file (for example, in indexAction, I can't get it to load the index.phtml file, no matter how hard I try).
Can someone tell me the best way to pass a variable from a controller to a view in the Zend Framework.
Upvotes: 1
Views: 1479
Reputation: 60413
In your controller:
$this->view->myvar = $value
In your subsequent view file:
<?php echo $this->myvar ?>
However it sounds like maybe youre having trouble getting the proper view itself to load? Typically this is auto configured by the Controller Action based on naming convention. If you need to use an alternate template you can do:
$this->render('viewname.phtml')
Perhaps you could ellaborate a little more and tell us what errors you get, and post some code of what you are doing in your controller and view that isnt working.
Upvotes: 4