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 Build a Simple PHP Application Creating the Menu and Footer Adding Active States to the Navigation

Orion Carrier
Orion Carrier
2,023 Points

Inconsistent results

Hi there,

In the "Adding Active States to the Navigation" lesson, we used a variable named $section to decorate, with an underline, the hyperlink of the page we're visiting, The $section variable is set in each page's script, before the header include, and a php conditional applies a css class "on" to the <li> containing the hyperlink if we are on the corresponding page.

My problem is, when I followed the video exactly, both links underlined no matter what page I was on, and one of the links' background went white.

After a bit of experimentation, I discovered that if I set $section == ""; before the header include in the index file, so that the variable exists and is set no matter what page I navigate to, then the link decorations worked exactly as in the video. But this is not what Randy did in the video.

Is this something Randy may have missed in the video, or is there something about PHP that I need to learn to get the results he showed in the video without the extra step I discovered?

I have a screen snapshot of what was happening if anyone needs to see that, but don't see a way to include it in this comment screen.

Thanks everyone...

3 Answers

Hi Orion,

I gave an answer to this in another thread here: https://teamtreehouse.com/forum/step-left-out-indexphp-contains-error-in-header

Check that link for an alternative solution.

Are you saying that you had problems on the shirts and contact page too? Or just the homepage? You probably have an additional error if all those pages have problems. The homepage should have both shirts and contacts underlined and the shirts link has a white background.

The shirts and contact page should be underlined correctly as shown in the video. If this is not the case for you then you should post your navigation markup with the scripts.

I think the reason we don't see the problem in the video is because Randy doesn't go back to the homepage in the video.

Randy Hoyt Is it possible to get a note added to this video about the problem?

Welby Obeng
Welby Obeng
20,340 Points

post the header code here

Orion Carrier
Orion Carrier
2,023 Points

Hi Welby and Jason, Thanks so much. I did see the plethora of questions on this matter after I already asked mine. I'll try to figure out how to look for existing questions before asking next time. ;P Meantime, thanks for the link, Jason. I'm going to be checking out Chrome Developer Tools and/or FireBug. Anything to help me find my own issues more efficiently and save a bunch of time. Cheers

Hi Orion,

Yes, I would recommend you get familiar with developer tools. They're indispensable.