Roxana Raicu
Roxana Raicu

Reputation: 3

How can I make Bootstrap and jQuery work in CodeIgniter?

I am new to Codeigniter and also to Bootstrap so when I tried to put the two together and also jQuery a problem arised. I have the following structure:

with the following coding: Views/Layout/content.php:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Doc</title>
<link rel="sylesheet" href="<?php echo base_url("assets/css/bootstrap.min.css");?>">    
<script type="text/javascript" src="<?php echo base_url("assets/js/jquery.js");?>"></script>
<script type="text/javascript"  src="<?php echo base_url("assets/js/bootstrap.min.js");?>"></script>

</head>
<body>

<div class="container">

 <div class="col-xs-6">


 </div>

 <div class="col-xs-6">

  <?php $this->load->view($content_view); ?>

 </div>
</div>
</body>
</html>

Views/home_view.php:

<h1>Hello </h1> <h2>Content goes here </h2>

Controllers/home.php:

class Home extends CI_Controller{

  public function index(){

   $data['content_view']="home_view";

   $this->load->view('Layout/content',$data);

   $this->load->helper('url');

  }

}

.htaccess:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]

The above and below coding includes everything relevant I could find on other Stackoverflow posts, Codeigniter documentation and also other web pages. Lastly, I also made the following changes to application/config.php:

$config['base_url'] = 'http://localhost/project/';
$config['index_page'] = '';

When I open the home page in the browser, the text is displayed normally (without any font/aligning changes - as it would have been if bootstrap was enforced). Moreover, I checked with Inspect element/View page source and neither Safari nor Google Chrome display anything to let me know that the files are not working. I downloaded the latest versions from jQuery (2.1.4) and Bootstrap (3.3.5). What other code/setting must I change in order to view the Bootstrap/jQuery implemented and the home.php text displayed accordingly in browser?

Thank you very much in advance for your help!

Upvotes: 0

Views: 1781

Answers (1)

user5450651
user5450651

Reputation:

Change this

<link rel="sylesheet" href="<?php echo base_url("assets/css/bootstrap.min.css");?>"> 

to

<link rel="stylesheet" href="<?php echo base_url("assets/css/bootstrap.min.css");?>">       

Upvotes: 2

Related Questions