Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.4k views
in Q2A Core by

I found a small bug.

Phenomenon:

Sub navigation with short URL than access URL is selected.

Example of OK case:

Sub nav1: http://example.com/mainnavi/sub1
Sub nav2: http://example.com/mainnavi/sub2

Example of NG case:

Sub nav1: http://example.com/mainnavi/sub
Sub nav2: http://example.com/mainnavi/sub2

When sub2 is accessed, sub is also selected.

Solution for V1.6:

qa-include/qa-page.php (around L245)

Before:

foreach ($qa_content['navigation'] as $navtype => $navigation)
  if (is_array($navigation) && ($navtype!='cat'))
    foreach ($navigation as $navprefix => $navlink)
      if (substr($requestlower.'$', 0, strlen($navprefix)) == $navprefix)
        $qa_content['navigation'][$navtype][$navprefix]['selected']=true;

After:

foreach ($qa_content['navigation'] as $navtype => $navigation) {
  if (is_array($navigation) && ($navtype!='cat')) {
    foreach ($navigation as $navprefix => $navlink) {
      if(strlen($navprefix) > strlen($requestlower))
        $len = strlen($navprefix);
      else
        $len = strlen($requestlower);
      if (substr($requestlower.'$', 0, $len) == $navprefix) {
        $qa_content['navigation'][$navtype][$navprefix]['selected']=true;
      }
    }
  }
}
Q2A version: 1.6 later
by
This issue has been discussed here.
https://github.com/q2a/question2answer/issues/152
by
Scott fixed this issue. This changes will be reflected in next version.
https://github.com/q2a/question2answer/issues/152

1 Answer

+3 votes
by
Just answering this to say that the issue is now fixed in 1.7-beta2.
...