简体   繁体   English

CakePHP布局未更改

[英]CakePHP layout not changing

I am working in CakePHP 2.3.0, I developed app using default layout. 我在CakePHP 2.3.0中工作,我使用默认布局开发了应用程序。 Now I need to change the layout to design.ctp but the app is rendering default.ctp 现在,我需要将布局更改为design.ctp但该应用程序正在呈现default.ctp

    public function myfun() {
      $this -> layout = 'design';

    }

I tried to clear the cache and switched ON the debug mode but the app is still picking the default.ctp 我试图清除缓存并打开调试模式,但应用程序仍在选择default.ctp

In your controller 在您的控制器中

class MyTestController extends AppController {
    var $layout = 'default'; 

and in your action try 然后在你的行动中尝试

public function myfun() {
  $this->layout = 'design';
}

Now, your view will use design.ctp, which is stored in views/layouts/. 现在,您的视图将使用design.ctp,该文件存储在views / layouts /中。

$this->layout = false; $ this-> layout = false; comment above line and it will work fine if you are palcing your lay 在上面的行中注释,如果您平躺,它将很好用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM