0
我想加载帮助程序取决于布局。 我想是这样的,但ID doesnt't工作:cakephp 2 - 根据布局加载帮助程序
function beforeRender(){
if (array_key_exists($this->request->action, $this->custom_layouts)){
public $helpers = array('Html', 'Form', 'Session', 'Menu1');
$this->layout = $this->custom_layouts[$this->action];
}else{
public $helpers = array(
'Session',
'Html' => array('className' => 'TwitterBootstrap.BootstrapHtml'),
'Form' => array('className' => 'TwitterBootstrap.BootstrapForm'),
'Paginator' => array('className' => 'TwitterBootstrap.BootstrapPaginator'),
'Menu1'
);
$this->layout = 'default';
}
}
感谢您的帮助 问候
请测试是否动态使用不同的佣工相同的别名(例如,有时$这个 - > HTML映射到“BootstrapHtmlHelper”有时到'HtmlHelper')按预期工作。为不同的类指定相同的别名可能会导致Cake缓存出现问题,并可能导致意外的结果(例如,随机附加'错误'类型的对象)。至少,'Models'就是这种情况,但同样的*可能*适用于其他课程 – thaJeztah 2013-02-08 21:04:01
非常感谢你的标记,作品完美。到目前为止,它正常工作 – mart 2013-02-08 21:23:03
@马丁很好听,只要确保测试与调试设置为0,因为只有然后缓存完全启用。 – thaJeztah 2013-02-08 21:35:52