LoginSignup
2
1

More than 5 years have passed since last update.

Cakephp3でViewのクラスを独自で設定したい

Posted at

やること

ViewをControllerごとに切り替えたい

前準備

Viewの下に設定したいClassを作る
(例 : HogeView)

やりかた

AppController.php
$this->viewBuilder()->setClassName('Hoge');

これを書くだけ。
メソッドで変えたい場合は

AppController.php
public function test()
{
    $this->viewBuilder()->setClassName('Hoge');
}

とすればメソッド単位で切り替えれる。

ディレクトリを切ることもできるので

AppController.php
$this->viewBuilder()->setClassName('Fuga\Hoge');

と書くことも出来る

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1