Issue
This Is hardik vyas, new to CodeIgniter, I have basic know-how about CodeIgniter. I want to include a template into CodeIgniter, but first of all I need to include an external stylesheet in a page, But I can't, I am facing a 403 error.
Here is my code:
Controller header.php
<?php
class Header extends CI_Controller{
function index(){
$this->load->view('header');
}
}
?>
View header.php
<html>
<head>
<title>demo</title>
<link rel="stylesheet" type="text/css" href="/application/views/mystyle.css"/>
</head>
<body style="background-color: antiquewhite">
<h3 style="background-color: #990000;color: #ffffff">Hello</h3>
</body>
</html>
CSS mystyle.css
.red {
background-color: red;
}
Please provide any simple way to do this and also please show me a simple way about how to include a template in CodeIgniter.
Solution
Your stylesheet(s) should not be inside of the CodeIgniter views
folder.
You folders should look like this:
/index.php
/css/mystyle.css
/codeigniter/application/controllers
/codeigniter/application/models
/codeigniter/application/views // <- no CSS in here
So your view should be:
<link rel="stylesheet" type="text/css" href="/css/mystyle.css"/>
If you want CSS in your views folder then I suggest this:
Folder
/codeigniter/application/views/css/mystyle.css
Code
<link rel="stylesheet" type="text/css" href="/codeigniter/application/views/css/mystyle.css"/>
Answered By - MonkeyZeus
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.