Today we will convert a professional HTML into CodeIgniter theme-
We will work on the following design layout
There are 5 parts in this template (1. Header, 2. Left menu, 3. Content area, 4. Right menu, 5. Footer)
For quick understanding we will break this template into three parts
Let’s get started now -
First off create a folder with the name “assets” where we will place CSS, JS, and Images.
On “CodeIgniter/application/config/config.php” confirm that we already have the base URL. If not it will be your_domain_name/root_folder_location.
Form “CodeIgniter/application/config/autoload.php”, you can set your libraries, helper, language etc.
Now follow the instructions below:
Note: if any folder(s) and file(s) is missing please create them according to the instruction.
Lets start by creating a file at application/controllers/pages.php with the following code.
Now create a folder into views with the name ‘templates’ which will contain the common parts of your template file.
Create two file into ‘templates’ with names ‘header.php and footer.php’ and add the following codes.
Create another folder into view with the name ‘pages’ which will contain only body part of pages. For example you want to create a page name ‘home.php’. Only body Body part will be written in this page.
Inside this folder create a page name ‘home.php’ and write a welcome message as below.
Now edit application/controllers/pages.php page as below –
Now open up a browser and type in http://localhost/CodeIgniter/index.php/pages/view. Hopefully you will see your home page –
Now let me break down why the URL will be like this http://localhost/CodeIgniter/index.php/pages/view
If you want some controller to load automatically then follow the steps below
Open “routes.php”, this is located in “/application/config/” relative to your root directory of CodeIgniter, for us, that would be “C:\wamp\www\CodeIgniter\application\config”
On line 41, you will notice:
$route['default_controller'] = “welcome”;
It should be:
$route['default_controller'] = “pages/view”;
Now visit http://localhost/CodeIgniter/ and that will display your home.php page.
Get FREE Web Development, Online Marketing and Smartphone App Creation Tips