Home >>Codeigniter Tutorial >Codeigniter Views

Codeigniter Views


The view is a simple webpage(designing page) which called by Controller.

The view may contain Navbar, Header, Footer, Sidebar, slider etc.

The view(designing page) can't access directly it always called by Controller.

Lets create a simple view page and call on a Controller's method. Ex

<!DOCTYPE html>
<title>About CI View</title>

	<h1>About Codeigniter Views</h1>

Save this file inside Application/views/about.php.

loading view on a controller

The view can be loaded on a controller following syntax :


Sometimes we can create different directly like user, admin etc. inside user directory we may store header, footer,sidebar for users same as admin inside admin directory, in this case we can call like :


Calling view on a Controller

Add a new mehtod about() on Hello Controller Application/controllers/Hello.php.

   class Hello extends CI_Controller
      public function index() 
         echo "Hello World"; 
	  public function about() 

Here Hello Controller has now 2 methods. One is index() that contains "Hello World" message only. Second method about() is calling about.php view page. Note : inside Controller no need to call page extension of view.

Calling about() method of Hello Controller



No Sidebar ads