Thursday, 16 June 2016

Create Simple Template in codeigniter

Easy Step to create Template in Codeigniter.

Step1. Create codeIgniter folder in c:\xampp\htdocs\.


Step2. And open your text editor. For example I am use Sublime text. And Write to below code and save to Home.php in C:\xampp\htdocs\codeIgniter\application\controllers folder.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends CI_Controller {
    public function index()
    {
        $this->load->view('home_view');
    }
}
?>



Step3. Create new page and save to  home_view.php in C:\xampp\htdocs\codeIgniter\application\views folder. and write to below code.

<!DOCTYPE html>
<html>
<head>
    <title>Simple Design Demo</title>
</head>
<body>
    <div style="width:50%; margin: auto; text-align: center; height:50; background-color:#DDD; padding:20px;">
        <h1 style="font-family:tahoma">Hello World</h1>
    </div>
</body>
</html>



Step4. Open routes.php file in C:\xampp\htdocs\codeIgniter\application\config\ folder. and edit below code.


$route['default_controller'] = 'Home';


Step5. Open your browser in your server. and run the program. with http://localhost/codeigniter/ or click in link. and view like this.




 

0 comments:

Post a Comment