Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Creating the Menu and Footer - Extra Credit - White background on header's "shirts" link

Hey guys,

I am doing the extra credit on this section and I have a somewhat weird issue where the background on the "shirts" list element in the header is white. The size of the element also changes as if there was a margin added to the bottom of the list element making the whole header larger. WIsh I could attach a screen capture...

It is the only element that has this white background and it only shows when I am browsing on the index.php file.

When I am on the other pages, the background for the list element dosen't change and stays orange.

I've only modified this part of the CSS in order to have my .png file fit on the header.

}
.header .nav li.on a {text-decoration: underline;}
.header .nav li a:hover, .header .nav li a:active {color: #FFE200;}
.header .nav li.shirts a {background-position: 0px 0px;}
.header .nav li.contact a {background-position: 0px -105px;}
.header .nav li.companyInformation a {background-position: 0px -415px;}
.header .nav li.cart a {
    width: 122px;
    font-size: 0/95px serif;
    text-shadow: none;
    color: transparent;
    background-position: 16px -216px;
    margin: 0;
}

Thanks!

2 Answers

Yo, if you right click on the shirts link and inspect / view the page source, can you see any php errors? Have you set the page title variable yet?

This is what I got when I inspected the shirts link element :

<li class="shirts <br />
<b>Notice</b>:  Undefined variable: section in <b>C:\xampp\htdocs\ShirtsForMike\inc\header.php</b> on line <b>17</b><br />
"><a href="shirts.php">Shirts</a></li>

So you're right there was an error! I didn't set a $section variable on the index.php page and a soon as I added it, the problem got solved!

Thanks Tom for your help on this one.

No worries, if you don't want to be forced into setting the $section variable for every page, you can run an isset() function. So in your li class attribute you could have:

<?php

if (isset($section) && $section == 'home) { echo "on"; }