0

Hey guys, I'm having an issue with loading multiple views in codeigiter.

$this->load->view('header');
$this->load->view('body-view', $data);
$this->load->view('footer');

The code above will allow me to load views right after each other on other servers I have worked on. For some reason, my server will only ouput one of these views at a time. I have been using codeigniter for a few years now, so I know that this is valid syntax.

Could it be an output issue with my servers configuration? Any help is much appreciated.

3
  • Have you verified that all views load completely without error when called individually? Commented May 2, 2013 at 2:39
  • I have checked each idividual view Commented May 2, 2013 at 2:49
  • 1
    You must have problem with your codeiginiter core files. Commented Feb 26, 2018 at 5:20

3 Answers 3

1

I resolved the issue. Some how i guess the package of codeigniter must have gotten corrupted. I just reconfigured codeigniter all over again with a fresh downloaded version and my code worked perfectly.

Sign up to request clarification or add additional context in comments.

Comments

0

Instead try this approach

$view = $this->load->view('header',array(),TRUE);
$view .= $this->load->view('body-view', $data , TRUE );
$view .= $this->load->view('footer',array(),TRUE);

echo $view;

Also check your html syntex it might be causing problem when loading multiple views. Please validate your html and try again.

1 Comment

Why do you think that this is different of what he was trying to do?
0
I guess you are not passing true parameter while passing view file.
please refer bellow tricks:
$output  = $this->load->view('your_view', 'your_data', true);
$output .= $this->load->view('your_other_view', 'your_other_data', true);
$output .= $this->load->view('your_last_view', 'your_last_data', true);
$this->output->set_output($output);

**Second Method, you can be passing view with data like :**
$data['header']  = $this->load->view('your_header_view_file_name', true);
$data['footer']  = $this->load->view('your_footer_view_file_name', true);
$data['your_necessary_data'] = $your variables ;
$data['your_necessary_data2'] = $your variables ;    
$this->load->view('blogview',$data);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.