お世話になります。
Cakephp3でのTemplateの切り替えでつまづいております。
CakePhP2.xの時は
PHP
1if ($this->request->is('mobile')) { 2 $this->viewPath = 'SmartPhone/' . $this->viewPath; 3 $this->layout='SmartPhone'; 4} else { 5 $this->viewPath = 'Pc/' . $this->viewPath; 6}
このようにViewを分けていたかと思います。
CakePHP3では
PHP
1if ($this->request->is('mobile')) { 2 $this->viewBuilder()->templatePath = 'SmartPhone/' . $this->viewBuilder()->templatePath(); 3 $this->viewBuilder()->layout("SmartPhone"); 4} else { 5 $this->viewBuilder()->templatePath = 'Pc' . $this->viewBuilder()->templatePath(); 6}
これで『$this->viewBuilder()->templatePath』をvar_dumpすると想定通りのパスが取得出来ますが、ブラウザを見てみるとスマホでもPC画面が表示されてしまっています。
どなたか正攻法をご存知でしたらお教えください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。