[英]Zend framework how can i get value from view and controller when render() is used?
I have this code in layout/formsde/url.phtml
: 我在
layout/formsde/url.phtml
有以下代码:
<?php
$use_url = $this->use_url;
foreach($this->match_de as $k=>$v) {
if($this->serverUrl(true) == $k) {
$use_url = $v;
}
}
?>
I have 1000 pages with following line: 我有以下页面的1000页:
<?=$this->render("layout/formsde/url");?>
Now the problem is $this->use_url
and $this->match_de
is null its not getting the value from Controllers where it is assigned as below: 现在问题是
$this->use_url
而$this->match_de
为null,它没有从分配如下的Controllers获取值:
return new ViewModel(array(
'description' => $this->de_desc,
'use_url' => $this->layout()->use_url,
'match_de' => $this->layout()->match_de,
));
How can i pass the value to ->render() ? 如何将值传递给-> render()? so that i have
$this->match_de
value with exact which is in controller? 这样我有
$this->match_de
值与确切在控制器中?
You can pass array with values you need to the render 您可以将具有所需值的数组传递给渲染
//Example
$this->render('layout/formsde/url', array(
'use_url' => $this->use_url,
'match_de' => $this->match_de));
Its possible to define variables in the template which is rendered by the view renderer Zend\\View\\Renderer\\PhpRenderer
. 可以在由视图渲染器
Zend\\View\\Renderer\\PhpRenderer
渲染的模板中定义变量。 You can pass an second argument as array. 您可以将第二个参数作为数组传递。
<?=$this->render("layout/formsde/url", array(
'description' => $this->de_desc,
'use_url' => $this->layout()->use_url,
'match_de' => $this->layout()->match_de,
));?>
More information about PhpRenderer::render() method can be found in the here . 有关PhpRenderer :: render()方法的更多信息,请参见here 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.