cakephp模板中未定义的变量



我只是迁移一个cakephp 2.5应用程序到服务器与PHP 7.2(之前服务器有5.6到7.1),所以我应该更新核心(2.10),最后得到正确显示应用程序,但我有问题时,url与参数加载。

错误是当我试图加载一个视图传递URL参数的控制器没有正确地传递数据到模板,并得到错误,如未定义变量:菜单[APP/view/Layouts/default。Ctp,第97行,所有变量

include - APP/View/Layouts/default.ctp, line 97 
View::_evaluate() - CORE/Cake/View/View.php, line 971 
View::_render() - CORE/Cake/View/View.php, line 933 
View::renderLayout() - CORE/Cake/View/View.php, line 546 
View::render() - CORE/Cake/View/View.php, line 481 
Controller::render() - CORE/Cake/Controller/Controller.php, line 968 
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 200 
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 167 
[main] - APP/webroot/index.php, line 109 

我很感激你的意见。谢谢。例如,我调用view localhost.com/administrator/Banners/editarBigHomePage?id=351,模板中充满了未定义变量的通知,这只发生在包含参数的url中。

下面是带有变量的视图:

public function editarBigHomePage()
{
$this->verificarUsuario();

if(!empty($this->request->params["url"]['id'])){
$id = $this->request->params["url"]['id'];
$categorias = $this->Categoria->find('all');
$this->set('categorias',$categorias);
$ciudades = $this->Ciudade->find('all');
$this->set('ciudades',$ciudades);
$publicidad = $this->Publicidade->findById($id);
$this->set('publicidad',$publicidad);
$this->set('menu','publicity');
$this->set('menu2','pase el menu por aqui');

}
if(!empty($this->request->data)){
$dataPublicidad= $this->request->data["Publicidade"];
$dataPublicidad["inhome"]=1; 
if($this->Publicidade->save($dataPublicidad)){
$this->Session->setFlash('Publicity Edited','success');
return $this->redirect(array('controller'=>'Banners','action'=>'listarBigHomePage'),null,true);
}else{
$this->Session->setFlash('Error Publicity No Edited');
return $this->redirect(array('controller'=>'Banners','action'=>'listarBigHomePage'),null,true);
}
}
}

相关内容

  • 没有找到相关文章

最新更新