Welcome Guest, Not a member yet? Register   Sign In
CSS won't load (using HTML helper)
#1

[eluser]IamPrototype[/eluser]
Hey, I'm new to CodeIgniter, and just started to make some different applications. My first problem is that my CSS won't load. When I check the source code, all the CSS (divs, classes, etc.) are wrote in the source code, and the URL for the CSS is 100 % right.

I created some views (header.php footer.php news.php). This is my header.php, or the top of it:

Code:
<?php
$link = array(
          'href' => 'css/default.css',
          'rel' => 'stylesheet',
          'type' => 'text/css',
          'media' => 'print'
);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
    &lt;title&gt;Prototype Design | Merry Christmas!&lt;/title&gt;
    &lt;?php echo link_tag($link); ?&gt;

My footer.php is just all the ending tags. Take a look on my news.php

Code:
&lt;?php
$this->load->view('header');
?&gt;
.....content etc.....
&lt;?php
$this->load->view('footer');
?&gt;

So yes, the weird thing is that in the source code the header and footer is loaded, but the CSS won't! Sad Anyways, so far I just love CodeIgniter, good job! Big Grin

** Yes, I've already tried including the CSS manual wise.
#2

[eluser]gullah[/eluser]
first off you'll probably want to get a template system. There are some in the wiki which will make your life a lot easier in the long run when you code gets more complicated and bigger.

You css is probably not working because it is probably not in the right folder. Link_tag files I believe load for your base url you set in your config and not in the system or system/application folder so make sure you have your css folder in the right place.
#3

[eluser]IamPrototype[/eluser]
I checked the source code, and it's the right CSS URL, and I don't want a template system, sorry.

** My CSS folder is placed in a folder called "ci" where the system, images, javascript are placed too.
#4

[eluser]gullah[/eluser]
taking a closer look at the link_tag you don't need all of the info you are putting in the array
so just try..

Code:
&lt;?=link_tag('css/default.css')?&gt;
#5

[eluser]IamPrototype[/eluser]
Now I used the code you just gave me, and this is written in the source code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
    &lt;title&gt;Prototype Design | Merry Christmas!&lt;/title&gt;
    &lt;link  href="localhost/ci/css/default.css" rel="stylesheet" type="text/css" /&gt;&lt;/head>
..rest of code

...and that's the right URL, I'm 100 % sure, I can type in the URl in my browser, and my CSS document appears.

** Nevermind, I got it to work. I just removed the code and manually wrote the code for CSS. Also I removed my base url etc., and just wrote "../../css/default.css" - that worked, I guess it's because I'm trying this on my local server. Thanks Smile
#6

[eluser]gullah[/eluser]
Are you developing this app on a local environment? If so I can see why it is working becuase localhost is sending you to you to your local environment with the folders ci/css/default.css where CI is looking for the folder localhost. Your base_url config is probably not configured correctly.
#7

[eluser]IamPrototype[/eluser]
Yup, that's why it wouldn't work, thanks Gullah. Smile




Theme © iAndrew 2016 - Forum software by © MyBB