0

hey everyone i'm facing a problem in codeigniter how to include css and jquery.

+application
  +views
    -welcome_message.php
  +assets
     +css
      -template.css
     +js
+system
+user_guide.


<link href='<?php echo base_url(); ?>application/assets/css/template.css' rel="stylesheet" type="text/css" />

firebug show path like:-

<link type="text/css" rel="stylesheet" href="http://localhost/CodeIgniter_2.1.3/application/assets/css/template.css">

i don't understand why it's css is not working.

i find this thing on firebug:-

<link type="text/css" rel="stylesheet" href="http://localhost/CodeIgniter_2.1.3/assets/css/template.css">
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /CodeIgniter_2.1.3/assets/css/template.css was not found on this server.</p>
</body></html>
</link>
4
  • 1
    and what is your question ??? the path isn't working ?? Commented Jun 12, 2013 at 8:17
  • Path is correct? or what do you expect? Commented Jun 12, 2013 at 8:18
  • css in not working.... Commented Jun 12, 2013 at 8:19
  • okey may be way of prviding path in not correct. Commented Jun 12, 2013 at 8:27

4 Answers 4

1

Best practice is to create an assets Directory outside the APPLICATION Directory not inside.

so you're directory structure would be

+APPLICATION
+ASSETS
+SYSTEM

its up to you how you divide the resources inside the ASSETS DIrectory

now you can use base_url()/assets/your-directories/yourfiles.ext to access whatever you wanted. Or create your own helper

i.e

style_url();
script_url();
image_url();
Sign up to request clarification or add additional context in comments.

Comments

0

Place css in root folder of site, inside assets dir and try this:

<link href='<?php echo base_url(); ?>assets/css/template.css' rel="stylesheet" type="text/css" />

Also, check image paths in it.

2 Comments

it's not working.i already tried it but sorry to say i doesn't work for me.
@Ankur Saxena: You need to move your assets folder to the root.
0

Try like this

<link rel="stylesheet" href="<?php echo site_url();?>/assets/css/template.css">

We cont use base url in some cases that your site url will include the index.php but your base url will not.And you need to give type="text/css" for this.

And also makesure that your css files should have the permissions to read and execute(may also)

Comments

0

So Simple

Set Your base_url in application/config/config.php file example given below

$config['base_url'] = 'your site url here';

After include CSS or JS files as

<!-- If Your Path is yoursitefolder/theme/css/style.css -->
<link rel="stylesheet" href="<?php echo base_url('theme/css/style.css'); ?>"> 

<!-- If Your Path is yoursitefolder/theme/js/vendor.js -->
<script src="<?php echo base_url('theme/js/vendor.js'); ?>"></script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.