Welcome Guest, Not a member yet? Register   Sign In
Calling multiple Views...

Obviously I'm new to CI...

I'm feeling pretty stupid right now because the simplest of simple things isn't working for me... Is there any reason why I keep getting an error message when I attempt to load more than one view from one controller? Am I not supposed to be loading two views at once?

class Main extends Controller {

function index()


I keep getting the message...

An Error Was Encountered
Unable to load the requested file: header_view.php

That doesn't make any sense, does it?

You are looking for the Layout Library: http://codeigniter.com/wiki/layout_library/

It does exactly what you are looking to do. Instead of a separate header and footer view file, you will only need one main view file to display both the header and footer.

This is how you would use it:

class Demo extends Controller
function __construct()



function index()
$templatedata['title'] = 'Hello world';

$this->layout->view('location/of/main_view', $template_data);


If the file can't be loaded it's due to one of two things.
1) The files permissions are incorrect, or
2) The file really doesn't exist.

In my experience, it's usually the latter.
With the load view calls you have, you'll need the following three files in your views directory:


Yeah. I'm thoroughly embarassed now. CodeIgniter is brilliant, yet humbling. It's been a frustrating day. I had the files in a different folder. Thanks for your reply Fuzzy.

Everybody makes mistakes, even more so when they're learning. I wish you every success with CodeIgniter. Stick with it, and I promise you won't regret it.

All the best!

Theme © iAndrew 2016 - Forum software by © MyBB