How To Create Layouts In Codeigniter 3.0

It's only fair to share...Share on Facebook0Share on Google+0Tweet about this on Twitter0Share on LinkedIn0Pin on Pinterest0Digg thisShare on StumbleUpon0


Codeigniter 3.0 does not have any layouts feature by default. We have to write some basic php code for enabling layout concept in codeigniter. In this tutorial we will explain how to create custom layout or template for CodeIgniter 3.0. In the below steps we assumes the page have 4 sections e.g header, footer, left panel and body area.

Follow the mentioned steps to create layouts or templates in codeigniter 3.0:

Step 1: Create a “MY_Controller.php” under “application/core/” and add below code:

Step  2:
Create a folder “layout” under “application/views/”.

Step 3: Create a file “header.php” under “application/views/layout/” for header section and add mentioned code

Step  4:
Create a file “footer.php” under “application/views/layout/” for Footer section and add mentioned code

Step 5:
 Create a file “left.php” under “application/views/layout/” for Left section and add mentioned code

Step  6:
Create front.php under “application/views/layout/” and add mentioned code

Step 7:
 Create a file “home.php” under “application/views/” for main body content

Step  8:
Create a controller “Home.php” under “application/controllers/” and add below code :

Finish!! Your basic layout for codeigniter has been ready for use.


  1. By Anuj


    • Reply

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">