Hi there, I'm a newbie, and I would really like some help regarding this issue I have with my menu.
First the code:
01 function public_navigation($sel_subject, $sel_page, $public = true) {
02 $output = '<ul id="sidebar_tags_ul">';
03 $subject_set = get_all_subjects($public);
04 while ($subject = mysql_fetch_array($subject_set)) {
05 $output .= "<li><a href=\"index.php?subj=" . urlencode($subject["id"]) . "\"";
06 if ($subject["id"] == $sel_subject['id']) { $output .= " class=\"selected_white\" . "; }
07 else { $output .= " class=\"sidebar_links_white\" . "; }
08 $output .= ">{$subject["menu_name"]}</a></li>";
09 if ($subject["id"] == $sel_subject['id'] || $subject["id"] == $sel_page['subject_id']) {
10 $page_set = get_pages_for_subject($subject["id"]);
11 $output .= "<div class=\"sidebar_links\">";
12 while ($page = mysql_fetch_array($page_set)) {
13 $output .= "<a href=\"index.php?page=" . urlencode($page["id"]) . "\"";
14 if ($page["id"] == $sel_page['id']) { $output .= " class=\"selected_orange\" . "; }
15 else { $output .= " class=\"sidebar_links\" . "; }
16 $output .= ">{$page["menu_name"]}</a>
";
17 }
18 $output .= "</div>";
19 }
20 }
21 $output .= "</ul>";
22 return $output;
23 }
Let me explain:
If I select a subject and if this subject has pages under it, the menu will expand and it will show all available pages in the selected subject. Fine!
However...if I then proceed to click on a page within the subject, the page does select but the menu collapses, and thus will not show all available pages in the subject anymore.
This means, in order to visit another page within the selected subject, I will first have to return to the selected subject (to open the menu) to be able to select another page inside the subject.
Now:
I did fool around a bit but could not get a satisfactory result. I added to line 09 in the if statement : || $subject["id"] == $sel_page.
Now the menu does not collapse on selecting a page, but if for example the $subject == 2 & $sel_page ==2, (wich is true in this case) then both will be selected if I select either of them.
What do I need to do to solve this problem?
Screenshot:
http://xtence.com.pt/images/screenshot.jpg