Zend Framework,传递变量查看 [英] Zend Framework, passing variables to view
本文介绍了Zend Framework,传递变量查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在显示视图时遇到问题.当我将 var 传递给视图时,视图不会呈现.
I have a problem with displaying a view. When I pass var to view, view doesn't render.
控制器:
public function indexAction()
{
$branchModel = new Application_Model_Branches();
$branches = $branchModel->getAllBranches();
$this->view->menu = $branches;
}
查看(index.phtml):
View (index.phtml):
<h2>Menu</h2>
<?php
$this->htmlList($this->menu);
?>
当我尝试调试 $branches
而不将其分配给查看时,一切似乎都可以,但是当我尝试将其推送到查看时,index.phtml 不会出现.
When I try debug $branches
without assign it to view, all seems to be ok, but when I try push it to view,index.phtml don't appear.
问候
推荐答案
您只是在代码中缺少回显,htmlList
视图助手返回一个值 - 它没有回显它.这里
You're just missing an echo in your code, the htmlList
view helper returns a value - it doesn't echo it. Some examples of the various form view helpers can be seen here
<h2>Menu</h2>
<?php
echo $this->htmlList($this->menu);
?>
这篇关于Zend Framework,传递变量查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文