From the course: PHP with MySQL Essential Training: 2 Build a CMS

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Solution: Collapsing navigation

Solution: Collapsing navigation

- [Instructor] Hopefully you did well with your first challenge assignment, to build a collapsing navigation. And this movie I'll show you the solution that I came up with. The first thing that I did was I went into the navigation and I wanted to make that link for each subject be meaningful, so I added the subject_id to it. I want it to be able to know which subject was currently selected. Now, there is the possibility that you could have tried to send the page_id to know which current page was selected since we're going to be showing that page's content to begin with, but that would have required me to figure out the page_id before I started my loop through all of the different navigation pages, and that's a little bit tricky to do. I need to know it up here, and there are ways that you can work around it. You could not display these three lines until we actually get inside the loop, but that's a little bit clunky. I think a more elegant way to do it is just to go ahead and submit…

Contents