how to load view into another view codeigniter 2.1?

Two ways of doing this:

  1. Load it in advance (like you’re doing) and pass to the other view

    <?php
    // the "TRUE" argument tells it to return the content, rather than display it immediately
    $data['menu'] = $this->load->view('menu', NULL, TRUE);
    $this->load->view ('home', $data);
    
  2. Load a view “from within” a view:

    <?php
    // put this in the controller
    $this->load->view('home');
    
    // put this in /application/views/home.php
    $this->view('menu');
    echo 'Other home content';
    

Leave a Comment