Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Bug report: selection of sub navigation

+1 vote
asked Nov 25, 2014 in Q2A Core by sama55

I found a small bug.


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)


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)


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);
        $len = strlen($requestlower);
      if (substr($requestlower.'$', 0, $len) == $navprefix) {
Q2A version: 1.6 later
commented Nov 26, 2014 by sama55
This issue has been discussed here.
commented Nov 28, 2014 by sama55
Scott fixed this issue. This changes will be reflected in next version.

1 Answer

+3 votes
answered Dec 9, 2014 by Scott
Just answering this to say that the issue is now fixed in 1.7-beta2.