Jump to content

CSS not loading from external stylesheet?


Tenaciousmug

Recommended Posts

Okay the reason I'm doing it this way is because I work locally and then transfer them to the production site.

For some reason, this isn't working even though when I view the page source, it has the right URL, but when it's clicked it goes to a blank page, but when I copy and paste, it goes to the right page.

 

Anywho, this is what I'm trying:

 

<?php $homeURL = 'localhost:90/Elvonica'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Elvonica</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?php echo $homeURL; ?>/template/css/skySpirit.css" />

 

I didn't plug in the rest to ignore it since it's not part of the problem. It's printing: localhost:90/Elvonica/template/css/skySpirit.css, but when it's clicked, goes to blank page. When it is copied and pasted, it goes to the right page.

I have a feeling you can't include PHP inside a link rel or any sort of that header information.

If anyone could please help me how to do this, I would appreciate it.

 

FYI:

I did have just template/css/skySpirit.css and it worked until I go into a another directory like forums/index.php. Then it tries to go localhost:90/Elvonica/forums/template/css/skySpirit.css and it's not in there obviously. :P

 

Thank you for anything that you can offer!

I know how to do the includes with the dirname(__FILE__).

There is no problem with using PHP to dynamically set ANY values in the HTML code - even the href for the style sheet. So, not sure what your problem is, but you don't need to set the value that way. As you found, when using "template/css/skySpirit.css" it will not find the style sheet with opening pages in sub folders. There is a very simple solution. Just put a slash at the beginning of the path and that will search from the root of the site rather than the root fo the current page location.

 

	<link rel="stylesheet" type="text/css" href="/template/css/skySpirit.css" />

 

Yeah if I put the slash infront of it, it shows this:

 

http://localhost:90/template/css/skySpirit.css

 

It doesn't include my /Elvonica folder that I have the whole solution in. I don't know how to fix that. I know it would probably work on the public server, but not my localhost machine since I have to put the whole project in a solution.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.