mrd*_*iri 8 cakephp cakephp-2.5
从2.5迁移指南:
$title_for_layout
已弃用.使用$this->fetch('title');
和$this->assign('title', 'your-page-title');
替代.
他们在视图中工作,但在Controller中做什么?使用$this->assign()
throws致命错误.
你必须使用
$this->assign('title',$title);
Run Code Online (Sandbox Code Playgroud)
在视图文件中.
在布局中,您也可以使用
$this->fetch('title', $title);
Run Code Online (Sandbox Code Playgroud)
设置标题
您可以使用,$this->set('title_for_layout',$title);
但不应该使用,因为它很快就会被删除
小智 4
只需在控制器的 function() 中设置它
$title = 'Title of your page | Site';
$this->set(compact('title'));
Run Code Online (Sandbox Code Playgroud)
然后您可以在视图中使用 $title 来更改页面的标题。:)
归档时间: |
|
查看次数: |
11154 次 |
最近记录: |