Welcome Guest, Not a member yet? Register   Sign In
Problem with CI url path
#1

[eluser]123XD[/eluser]
Hi all,

I just had this problem during development``
in my index file I have something like

Code:
<link rel="stylesheet" href="/system/application/views/css/main.css" type="text/css" />

and in the css file I have

Code:
body
{
  background: url(/system/application/views/images/bg.gif) top repeat-x #000033;
}

What I am trying to do is that to make the path to css or to image flexible, so that I don't need to change all of these, while I put the application to other directory or changing it's path.
I have read some of the post related 'base_url()', but I am still not getting the idea.

Could any one give me a example of that? that would be very helpful.Thanks!

Cheers,
#2

[eluser]esra[/eluser]
Code:
<link rel="stylesheet" href="<?=base_url();?>application/views/css/main.css" type="text/css" />

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

Use the former if short tags are enabled in php.ini or if you have forced short tags using config.php. Use the latter if you don't want to use short tags.

An alternate solution is to use assets_helper by Nick Cernis. Do a forum search to find the code in a thread.




Theme © iAndrew 2016 - Forum software by © MyBB