CodeIgniter Forums
CSS not applying for controllers with 3+ URI segments in URL? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CSS not applying for controllers with 3+ URI segments in URL? (/showthread.php?tid=11730)



CSS not applying for controllers with 3+ URI segments in URL? - El Forum - 09-21-2008

[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?


CSS not applying for controllers with 3+ URI segments in URL? - El Forum - 09-21-2008

[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.


CSS not applying for controllers with 3+ URI segments in URL? - El Forum - 09-21-2008

[eluser]inktri[/eluser]
thanks, worked


CSS not applying for controllers with 3+ URI segments in URL? - El Forum - 09-21-2008

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

-Lee


CSS not applying for controllers with 3+ URI segments in URL? - El Forum - 09-21-2008

[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


CSS not applying for controllers with 3+ URI segments in URL? - El Forum - 09-21-2008

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