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
Tiffany Hsieh
2,130 Points"Adding Active States to the Navigation"
I think that there's a typo somewhere in the lesson as well as in the project file zip. Everything was fine up until I had to edit "header.php" and add the conditional statement. I tried downloading the lesson files and pasting it into my code, but it seems like there's a typo in the files since it displays the webpage without any formatting.
Also, can someone please explain this part of the code: if ($section == "shirts") { echo "on"; } I understand the "if" part, but doesn't {echo "on";} just print out "on"? I know the objective is to activate the class to underline it, but I don't understand how that command does that.
Any suggestions are appreciated! Thanks
1 Answer
Sean Washington
12,330 PointsHey Tiffany,
I haven't actually done the lesson myself, so I can't speak for the typo in the lesson, but I can explain the second part for you.
It looks like we're passing a variable called $section from a page into header.php. That if statement looks to see if the var $section is equal to shirts. If it is, it does in fact print "on". This way, we can do something like
<li <?php if ($section == "shirts") { echo 'class= "on"'; } ?>>List item</li>
If $section equals shirts, then we will end up with
<li class="on">List Item</li>
and target .on in the css to give that list item or link an underline like so:
.on { text-decoration: underline; }
Hope that quick explanation helps!