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

你不能仅仅public $helpers在方法内部声明。

您需要调用它,因为 PHP 希望它被调用:

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