Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
681 views
Welcome To Ask or Share your Answers For Others

1 Answer

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...