Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Load view into another view in codeigniter

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 220
    Comment on it

    We can load view into another view in codeigniter by creating a helper function and place the following code.

    function loadView($view,$data = null){
        $CI = get_instance();
        return $CI->load->view($view,$data);
    } 
    

    Next in the controller load helper function and then use this function in your view to load another one.

        <?php
    
    echo loadView('secondView',$data); 
    
    //where $data is the array
    
    ?>
    

    Secondly We can also load view in another view by using this way also.

    <?php
    
    $data['val'] = $this-&gt;load-&gt;view('val', NULL, TRUE);
    
    $this->load->view ('val2', $data);
    ?>
    

    Where true indicates that it will return the content.

 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: