I'm just starting with CI, and am not sure where things such as css, js, images should go.
Outside the whole system folder seems ok, but that means everything is seperate. Inside mean s the filepaths are longer and I'm worried that it might mess things up.
What's the official line on this?
-
I usually put separate folders at the root level, so I end up with a directory structure like this:
/system /css /js /img
Seems to work for me - when you use
site_url(url)
, the URL it generates is from the root, so you can usesite_url('css/file.css')
to generate URLs to your stylesheets etc.Rich Bradshaw : Ah, that makes sense. I wanted to be able to use site_url, so this makes sense. Thanks!From Phill Sacre -
I hate having so many directories at the root level, so I use /public and use htaccess to rewrite /scripts to /public/scripts and so on.
From eyelidlessness -
I find it best to keep the assets on the root level. You can use
<?=base_url()?>
to echo the full root of the site. In the config file, you set up the root of the website. This statement just echoes that out.Because of this, you can use includes like this:
<link href="<?=base_url()?>/css/style.css" rel="stylesheet" type="text/css" />
anywhere in your code, and it will still get http://example.com/css/style.css.
From Click Online Design -
There's a article/FAQ that discusses this in CI's wiki. It seems a good way to setup you application.
From Clutch -
thank u so much for this solution i am bothering about base url now you have provided me best solution thanks for it
From hamza khan -
base_url()/css/name.css
Mitchell McKenna : base_url() actually includes the trailing slash so you'd want: base_url() . 'css/name.css';Tejas1810 : ok.ok.thanks .i know but i m forgot to put itFrom Tejas1810
0 comments:
Post a Comment