adding bootstrap to codeigniter
For adding bootstrap to your website, you need to add Bootstrap CDN or need to download the bootstrap from the website of bootstrap. If you download the boostrap, then you should place that bootstrap file in a new folder in application.
Here i am using Bootstrap CDN. Now we are going to create two pages header.php and footer.php as follows:
header.php
footer.php
Now let us add these files to the controller :
Now we are all set. You can now use the bootstrap by adding header.php and footer.php to any page.
Here i am using Bootstrap CDN. Now we are going to create two pages header.php and footer.php as follows:
header.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
footer.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>
Now let us add these files to the controller :
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Home extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view("home");
}
public function login()
{
$this->load->view("header");
$this->load->view("login");
$this->load->view("footer");
}
}
Now we are all set. You can now use the bootstrap by adding header.php and footer.php to any page.
⇐Prev
Next⇒
Comments
Post a Comment