0
레이아웃에 따라 도우미를로드하고 싶습니다. 내가 이런 식으로 뭔가를 원하지만 아이디 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';
}
}
감사 관련
테스트하십시오 때로는 :
당신은 PHP가 호출되고 싶어로 호출 할 필요가 'HtmlHelper')는 예상대로 작동합니다. 동일한 별칭을 다른 클래스에 할당하면 Cake 캐시에 문제가 발생할 수 있으며 예기치 않은 결과가 발생할 수 있습니다 (예 : '잘못된'객체 유형을 무작위로 첨부). 적어도 이것은 '모델'의 경우입니다. 그러나 다른 클래스에도 동일하게 적용될 수 있습니다. – thaJeztah
대단히 감사드립니다. 완벽하게 작동합니다. 지금까지는 예상대로 – mart
@martin이 좋은 결과를 얻었지만 디버그를 0으로 설정하여 테스트했는지 확인하십시오. 단지 캐싱 만 사용 가능하기 때문입니다. – thaJeztah