CodeIgniter Forums

Full Version: CSS not applying for controllers with 3+ URI segments in URL?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]inktri[/eluser]
For example, I've got a controller called "user". Accessing:
http://localhost/user/bob/three
loads the page correctly HOWEVER the CSS doesn't apply


I handle the user view page with a "master view".

Code:
$this->load->view('header', $data);
$this->load->view($view);
$this->load->view('footer');

CSS style sheet is declared in the header view and it's located in /var/www/css/
Code:
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" />

Anyone know why the CSS isn't applying?

El Forum

[eluser]Popcorn[/eluser]
Use

Code:
<link rel="stylesheet" href="<?php echo base_url() ?>/style.css" type="text/css" media="screen" />

Instead. Make sure you have the URL helper loaded.

El Forum

[eluser]inktri[/eluser]
thanks, worked

El Forum

[eluser]CI Lee[/eluser]
Do you understand why it was broken?

-Lee

El Forum

[eluser]compoundeye[/eluser]
i'm guessing because you used a relative path to your css file:

../css/style.css

that when you start adding segments,

http://localhost/user/bob/three

it is interpreted as folders perhaps? so maybe its looking for

http://localhost/user/bob/css/style.css

instead of

http://localhost/css/style.css?

just a guess, if you really wanted to know you could create

http://localhost/user/bob/css/style.css
and
http://localhost/user/css/style.css
etc

to see what effect it has

cheers

mat

El Forum

[eluser]Colin Williams[/eluser]
It might help to study some of these basics before diving into actual development.