Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to apply layout in CakePHP ?

    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 213
    Comment on it

    In CakePHP, there is by default layout in (app/View/Layouts/default.ctp) file, But there are many cases in which we can apply different layout in pages as per our client requirement.
    Case- 1 If we dont want any layout for our controller method, then we set the layout property Null.

    class UsersController extends AppController {
    
       Var $layout = Null; // For all actions
    
        public function index(){
           $this->layout = Null; // For particular action 
        }
    }
    

    Case- 2 If we want to apply multiple layout in our pages, then we set different layout in our action.

    function index() {
    $this->layout='indexlayout'; //app/views/layouts/indexlayout.ctp
    }
    function view() {
    $this->layout = 'viewlayout'; //app/views/layouts/viewlayout.cpt
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: