0

The image below (at the very bottom) is the file structure for the site I'm building, where I can't connect the CSS file properly.

In directory Public/Admin/ there is a file login.php. From login.php, I use the following function call...

to get the header for the login.php page.

The function it calls in the (Includes/functions.php file) is this

function include_layout_template($template=""){
include(SITE_ROOT.DS.'public'.DS.'layouts'.DS.$template);
}

which gets the admin_header.php file from the LAYOUT directory. I know the admin_header.php is loading properly into the login.php file using this function call because the html of the admin_header.php file is appearing when i load login.php. However, the admin_header.php file also has the link to the main.css file in the StyleSheets directory

<link href="../stylesheets/main.css" media="al" rel="stylesheet" type="text/css"/>

Although, as mentioned, admin_header.php is being incorporated into public/Admin/login.php, the stylesheet is not working.

Looking at the directory structure below, is there something wrong with my link to the stylesheet?

Picture of file structure

3
  • Check out the link to the style sheet inside the document's source code using Chrome or Firefox. The link is clickable there. If you get a 404 in return, it is broken Commented Mar 11, 2011 at 10:04
  • @pekka how do I do that? can you please explain a bit more. thank you.. I'm a newbie Commented Mar 11, 2011 at 10:06
  • use the browser's "View source" function, the shortcut should be Ctrl + U in both browsers (not 100% sure because of international differences in layout.) Commented Mar 11, 2011 at 10:08

4 Answers 4

3

It's not the relativity of the file location that is your problem. You have media="al" when it should be media="all". This should fix it.

Sign up to request clarification or add additional context in comments.

Comments

2

The stylesheet's URL is relative to the generated HTML file, not the PHP file. I usually solve this by using absolute URLs, which means storing the base URL of the site somewhere (probably a configuration file) and then include all JS/CSS file like this:

<?php echo BASEURL ?>/css/style.css

Comments

0

Hi you are in your public folder after one ../ and your include folder is at the same level. You need to step up one step more.. /../

Comments

-2

Simple trick is that if you rename the css file by SAVE AS option and create link for it. It will definitely work.

1 Comment

Why should the file be renamed? Please add some explanation to your answer such that others can learn fro mit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.