- This topic is empty.
-
AuthorPosts
-
July 5, 2014 at 2:23 am #174671
KKHAN
ParticipantHi i am having problem with includes. Specifically when including my head which contains the link to the style.css. Although the style.css applies to the index page. It does not for my other .php files which are nested in a folder.
Structure
-ROOT
-INCLUDES
-OVERALL
overallHeader.php
overallFooter.php
-STYLE
style.css
head.php
footer.php
header.php
index.php
-PROFILE
dashboard.phpMy stylesheet is working for index.php but not dashboard.php. In dashboard.php, just like index.php i am including the overallHeader.php which includes the header.php and the head.php (which contains the link rel to style.css).
However, in index.php for the style to work i am including the overallHeader like this…
<?php include ('includes/overall/overallHeader.php'); ?>
Where as in dashboard.php i am including the overallHeader like this.
<?php include ($_SERVER['DOCUMENT_ROOT']."/includes/overall/overallHeader.php");?>
By using the the document root, it works because i can see the html output just the style is not applied.In my head.php i am using
<link rel="stylesheet" type="text/css" href="includes/css/style.css">
Is there something i need to change to href, i have tried prefix echoing the document_root, but then the style.css does not work for index.php.
If i check the logs in dashboard.php it shows this.
“NetworkError: 404 Not Found – http://localhost:63342/MYSITE/profile/includes/css/style.css” which is wrong.
July 5, 2014 at 3:05 am #174674chrisburton
ParticipantTry something like this:
<link rel="stylesheet" type="text/css" href="<?php echo $_SERVER["DOCUMENT_ROOT"].'../includes/css/style.css'; ?>">
July 5, 2014 at 3:28 am #174678KKHAN
ParticipantUsing your method the style does not show up on both dashboard and index.php
But whats weird is there is no console error for style sheet, there is for the script.js but i can fix that later.
Seems odd. Firebug css is still not showing though.
July 5, 2014 at 3:32 am #174679chrisburton
Participant@KKHAN Fixed the above code. I forgot the echo.
Note: you may have to play with
../includes/
depending how deep the directories go.For example, dashboard.php would require
../includes
where as index.php would requireincludes/
July 5, 2014 at 3:38 am #174680KKHAN
ParticipantThis did not work for this reason.
C:/xampp/htdocs/MYSITE../includes/css/style.css
This is what your statements echos out. ive removed the “..” still doesen’t work.
MY includes all have $_SERVER[‘DOCUMENT_ROOT’]. They bring back the html so i assume they are all working. Just the css won’t apply.
July 5, 2014 at 3:42 am #174681chrisburton
ParticipantIf it is outputting this:
C:/xampp/htdocs/MYSITE../includes/css/style.css
Then it should look like this: http://hastebin.com/wuduzoxuwe.xml
`I had to post it on hastebin because CSS-Tricks was throwing a firewall error.
July 5, 2014 at 3:51 am #174682KKHAN
ParticipantThat code would show this, which it does.
July 5, 2014 at 3:53 am #174683KKHAN
ParticipantCan’t post what i want because of firewall
July 5, 2014 at 3:54 am #174684chrisburton
Participant@KKHAN use http://pastebin.com.
Paste what you’re trying to show me, click submit and post the URL in the address bar.
July 5, 2014 at 4:00 am #174685Senff
ParticipantHow about this?
<link rel="stylesheet" type="text/css" href="/includes/css/style.css">
Notice the slash before “includes”.
July 5, 2014 at 4:01 am #174686July 5, 2014 at 4:04 am #174688KKHAN
ParticipantNope that wouldint work console error log
http://localhost:63342/includes/css/style.css
it complete misses the MYSITE folder.
July 5, 2014 at 4:09 am #174691chrisburton
Participant@KKHAN Ok, wait a second. What file are you pasting that in?
It might also help if you paste the path to where the .css file is you’re trying to include and also the path to the .php file you are having trouble getting the css to work in.
July 5, 2014 at 4:38 am #174695KKHAN
ParticipantI am pasting it in the mysite/includes/head.php file.
Which gets included in the
mysite/includes/overall/overallHeader.php file
which gets included in the
mysite/profile/dashboard.php file and
mysite/index.php fileJuly 5, 2014 at 4:49 am #174707chrisburton
Participant@KKHAN Can you paste what is inside head.php and /overall/overllHeader.php on pastebin? Preferably two separate ones.
If you’re saying that the following is correct but not applying the CSS:
<link rel="stylesheet" type="text/css" href="<?php echo $_SERVER["DOCUMENT_ROOT"].'/includes/css/style.css'; ?>;">
I would ask you to view the page source and click the link that outputs that and tell me if it directs you to the CSS file.
If it does, I’m not exactly understanding your problem. Are you trying to say that it only works within a specific directory and nothing deeper?
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.