从2.5 迁移指南:
$title_for_layout
已弃用。使用$this->fetch('title');
and$this->assign('title', 'your-page-title');
代替。
它们在 Views 中工作,但在 Controller 中该怎么办?使用$this->assign()
会引发致命错误。
从2.5 迁移指南:
$title_for_layout
已弃用。使用$this->fetch('title');
and$this->assign('title', 'your-page-title');
代替。
它们在 Views 中工作,但在 Controller 中该怎么办?使用$this->assign()
会引发致命错误。
利用
$this->set('title_for_layout', 'List User');
内部控制器。
你必须使用
$this->assign('title',$title);
在视图文件中。
在布局中,您还可以使用
$this->fetch('title', $title);
设置标题
您可以使用$this->set('title_for_layout',$title);
但不应该使用,因为它将很快被删除
只需在控制器的 function() 中设置它
$title = 'Title of your page | Site';
$this->set(compact('title'));
然后您可以在视图中使用 $title 来更改页面的标题。:)