Page 1 of 1
Styling an Include
Posted: Wed Jul 14, 2010 12:14 pm
by deadkenny
Greetings! I posted this in other sections, but this area also seemed to apply. I am encountering an issue that I cannot seem to resolve on my own, and my search efforts have turned up minimal information. I created the following page:
http://mspsinc.com/nprojects.html
I wanted to turn the navigation(s) into a reusable PHP and include it on each page, but when I do, the styling does not seem to come through (or is being somehow overridden by something) and the links turn out blue. Here is the result:
http://mspsinc.com/nprojectsphp.php
and the included php navigation is located here:
http://mspsinc.com/navigation.php
I tried also linking the style sheet to the navigation.php, which styles fine when visited directly, but produced the same result when view through the page it is included in (nprojectsphp.php).
This seems like it should be a pretty simple solution, but this is my first time writing PHP. Please... HELP!
Re: Styling an Include
Posted: Wed Jul 14, 2010 1:43 pm
by Christopher
Please only post once per question.
The page that works loads "main.css" while the page that does not work loads "/main.css".
Re: Styling an Include
Posted: Wed Jul 14, 2010 1:46 pm
by deadkenny
Since both pages are in the root directory, it is referencing the same file. I read somewhere to try adding the / as a fix for a bug or something, but it obviously does not work. The funny thing is that the text decoration from the style is being applied (with the proper color) but the text color is somehow being made blue.
Re: Styling an Include
Posted: Wed Jul 14, 2010 2:28 pm
by Weirdan
Pretty simple indeed. You misspelled rel="stylesheet". You have:
Code: Select all
<link href="/main.css" rel="styleshe et" type="text/css"/>
while it should be
Code: Select all
<link href="/main.css" rel="stylesheet" type="text/css"/>
Re: Styling an Include
Posted: Wed Jul 14, 2010 2:45 pm
by deadkenny
Even with the misplaced tab, it was still rendering fine when you visit the navigation.php alone, and even with the misplaced tab removed, it is still misbehaving.
Re: Styling an Include
Posted: Wed Jul 14, 2010 4:01 pm
by Weirdan
All your links are wrapped in divs with 'bumplinksCurrent' class on your php page (while your html version uses .bumplinks class), and there's no style defined for '.bumplinksCurrent a', thus the only style that applies is global 'a' style from main.css. And that one does not define color.
Re: Styling an Include
Posted: Thu Jul 15, 2010 3:55 pm
by deadkenny
I am still confused about 2 things. Why is the styling applied correctly when visiting the
http://www.mspsinc.com/navigation.php , and where is it getting the text decoration from (since the global link style is this:
a {
text-decoration:none;
}
I suppose the only difference between the separate navigation.php and the page the has it included is the <?php $thisPage="BAP"; ?> so there could be something wrong with my if/else code? I am such a newb!
Re: Styling an Include
Posted: Thu Jul 15, 2010 4:16 pm
by Weirdan
on navigation.php links are wrapped with divs having 'bumplinks' class, while on nprojectsphp.php they are wrapped with divs having 'bumplinksCurrent' class. That's the difference.
Re: Styling an Include
Posted: Thu Jul 15, 2010 4:27 pm
by deadkenny
navigation.php contains numerous links coded like this :
Code: Select all
<div <?php if ($thisPage=="BAP") {
echo " class=\"bumplinksCurrent\"";
}else{
echo " class=\"bumplinks\"";
}?>>
<a href="nullz">Bel Aire Plaza<br /><span style="font-size:9px">Napa, CA</span></a></div>
<div <?php if ($thisPage=="BB") {
echo " class=\"bumplinksCurrent\"";
}else{
echo " class=\"bumplinks\"";
}?>>
<a href="nully">Borreo on the River<br /><span style="font-size:9px">Napa, CA</span></a></div>
So it appears that error may well be inside the if/else code I am attempting to use to make the link to the current page have a separate style from the others, like on this page:
http://www.mspsinc.com/nprojects/pm/overview.html
Re: Styling an Include
Posted: Thu Jul 15, 2010 4:44 pm
by Weirdan
what does <?php var_dump($thisPage); ?> show if you put it into navigation.php ?
Re: Styling an Include
Posted: Thu Jul 15, 2010 4:47 pm
by deadkenny
Re: Styling an Include
Posted: Fri Jul 16, 2010 12:30 pm
by Weirdan
and it seems now only one link is styled as 'current' - now all you need is to define styles for '.bumplinksCurrent a'