Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We can use conditionals and variables to make further changes to the HTML output on different pages. In this video, we’ll add a new variable and use a conditional to check its value in our main navigation menu.
Update to html
index.php unordered list for our random items should have a class of "items".
<ul class="items">
Preventing Errors
If you forget to add the $section variable to a page, you could see an error. This is why we set "$section = null;" on the index page. If you want to make sure you code works without an error even if $section is not defined, you could include the isset function in you if statement as well.
Example:
if (isset($section) && $section == "books")
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up