CSS not load at somecontroller/somefunction/someid |
[eluser]Keem1[/eluser]
I've just started using CI but have a problem. If I load a page like this: index.php/something/ the CSS files load well, but type index.php/something/other/ the CSS files not load. How can I tell to CI, the main directory is where index.php is stored? Or anything else to solve this problem? I'm very-very new, but I want to learn all CI practices. Oh, before I forget, an other question. My new website's views load a constant view as header. Is there any chance to load once after initializing, instead of load in each views? Ps: Sorry for my English, I'm Hungarian :-)
[eluser]CroNiX[/eluser]
Not sure about your css issue, but as far as your 2nd question, here's what I do: I create a helper function that has 2 parameters (title and main content). I have several views that get populated for each page and only the content portion changes. Library that I autoload containing functions: Code: //helper function to generate a main page with the passed in title and content. Then I just have to: Code: $this->global->make_page('Title of this page', $this->load->view('somedir/someview', $data, TRUE));
[eluser]pistolPete[/eluser]
[quote author="Keem1" date="1236122788"]If I load a page like this: index.php/something/ the CSS files load well, but type index.php/something/other/ the CSS files not load. How can I tell to CI, the main directory is where index.php is stored? Or anything else to solve this problem?[/quote] Are you using relative paths in your views? Please post your view code.
[eluser]Keem1[/eluser]
[quote author="pistolPete" date="1236125730"]Are you using relative paths in your views? Please post your view code.[/quote] Yes, relative because I'll use the same site on localhost and web server. Here's my header_view.php file. The "style" folder is in the same folder where the system and index.php. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> CroNiX: I'm going to try your code, thanks!
[eluser]pistolPete[/eluser]
[quote author="Keem1" date="1236126435"]Yes, relative because I'll use the same site on localhost and web server.[/quote] You can use absolute paths without specifying the domain / server adress. Add a forward slash at the beginning of the path: Code: <link href="/style/mainstyle.css" rel="stylesheet" type="text/css" /> http://<<host>>/style/ You have to adjust the path above if it's different!
[eluser]Keem1[/eluser]
[quote author="pistolPete" date="1236128175"] You can use absolute paths without specifying the domain / server adress. Add a forward slash at the beginning of the path: Code: <link href="/style/mainstyle.css" rel="stylesheet" type="text/css" /> http://<<host>>/style/ You have to adjust the path above if it's different![/quote] Oh, my god... it works! How did this not occur to me? Thank you!
[eluser]xwero[/eluser]
a function to show how the server sees the relative path |
Welcome Guest, Not a member yet? Register Sign In |