Reputation: 55
I am totally new in CodeIgnitor. In the controllers folder I created a file named caller.php
and I created a file home.php
in views. In views I also created a folder named css
and I created style.css
in that css
folder. In views I have some pictures. Those pictures are also part of design. Now I want to use style.css
and the pictures. But I can't.
In caller.php I have:
class caller extends CI_Controller
{
function index()
{
$this->load->view('home');
// What do I have to write here to load css?
}
}
In home.php I have:
<html>
<head>
***------what i have to write here to load css--------***
</head>
<body>
<div id="outer">
...
</div>
</body>
</html>
If additional configs are needed please mention that.
Upvotes: 2
Views: 3874
Reputation: 365
Thanks so much @ Malachi. <link href="<?php echo base_url();?>assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
is my file path & not working.
I have used
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
on my .htaccess file & it's working now smoothly. assets is my file file path
Upvotes: 0
Reputation: 33690
Leading on from what Oliver said of including the stylesheet with:
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css">
If you have removed index.php from your URL's make sure you include your css directory in the rewrite rule.
RewriteEngine on
RewriteCond $1 !^(index\.php|css)
RewriteRule ^(.*)$ /index.php/$1 [L]
This is assuming your stylesheet is located in a folder called css
at the root of your application.
- index.php
+ system
+ application
+ css
- style.css
Make sure that you have enabled the URL helper to use commands such as base_url()
. This can be done globally inside config/autoload.php
by adding url to the helper array.
$autoload['helper'] = array('url');
Upvotes: 3
Reputation: 8029
add
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/style.css">
into home.php between <head>
and </head>
tags
and make sure the style.css is in a css folder in the main directory
Upvotes: 0