开发者

Sending the Variables from Layout to comtroller and view in zend framework

I have a php array defined in "layout" known as default.phtml and that array is some thing like this

$mydata['abc'] = array("A","A","A","A","A","A","A");

I can get the Layout using a custom defined function

$cls = new  cass();
$layout = $cls->getLayout() ;

How do I access the same array 开发者_如何学Go$mydata['abc'] in the Controller and view.


You should move this array to your controller. I think it's not a good pratice put data hard-coded in your view.

Also, I think you can't get a variable defined in your view. When you use getLayout() method you are getting not the html code, but the component that render your layout, so you can call disableLayout() for example. But, even if it was the html, before you get it, the html and php code would be processed first and all of your variables would be lost. So, I think you should change your logic and pass this variable from your controller to your view.

Maybe if you post more information about what you are really trying to achieve, we can say the best way to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜