Views
A view is simply a web page, or a page fragment, like a header, footer, sidebar,t, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type of hierarchy.
Views are never called directly, they must be loaded by a controller. Remember that in an MVC framework, the Controller acts as the traffic cop, so it is responsible for fetching a particular view. If you have not read the Controllers page you should do so before continuing.
Using the example controller you created in the controller page, let's add a view to it.
Creating a View
Using your text editor, create a file called blogview.php, and put this in it:
Then save the file in your application/views/ folder.
Loading a View
To load a particular view file you will use the following function:
$this->load->view('name');
Where name is the name of your view file. Note: The .php file extension does not need to be specified unless you use something other then .php.
Now, open the controller file you made earlier called blog.php, and replace the echo statement with the view loading function:
If you visit the your site using the URL you did earlier you should see your new view. The URL was similar to this:
www.your-site.com/index.php/blog/
Loading multiple views
CodeIgniter will intelligently handle multiple calls to $this->load->view from within a controller. If more then one call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view. That might look something like this:
<?php
class Page extends Controller {
function index()
{
$data['page_title'] = 'Your title';
$this->load->view('header');
$this->load->view('menu');
$this->load->view('content', $data);
&n