2010-09-22 96 views
2

我在显示视图时遇到了问题。当我传递var来查看时,视图不会呈现。Zend Framework,传递变量以查看

控制器:

public function indexAction() 
{ 
    $branchModel = new Application_Model_Branches(); 
    $branches = $branchModel->getAllBranches(); 
    $this->view->menu = $branches; 
} 

视图(index.phtml):

<h2>Menu</h2> 
<?php 
    $this->htmlList($this->menu); 
?> 

当我尝试调试$branches不分配它来查看,一切似乎是确定,但是当我试图将其推查看,index.phtml不会出现。

问候

+1

你的代码看起来不错。如果你在你的index.phtml中var_dump($ this-> menu),这是否工作? – 2010-09-22 18:29:07

回答

12

你只是缺少一个回波在你的代码中,htmlList视图助手返回一个值 - 它没有回音了。各种形式的视图助手的一些例子可以看出here

​​
2

控制器

$this->view->variableName = "Hello World!";//assign here   

    $this->view->assign('variableName1', "Hello new World!");//assign here 

视图

echo $this->variableName;//echo here 

    echo $this->variableName1;//echo here