0

レイアウトに応じてヘルパーをロードしたいのですが。このようなものが欲しいのですが、idが機能しません:

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';
  }
} 

よろしくお願いします

4

1 に答える 1

2

メソッド内でjuse宣言することはできませんpublic $helpers

PHPが呼び出す必要があるため、呼び出す必要があります。

$this->helpers[] = 'Menu1';
$this->helpers['Html'] = array('className' => 'TwitterBootstrap.BootstrapHtml');
...
于 2013-02-08T17:51:40.050 に答える