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

how to change navlink path sub menu

+1 vote
asked Sep 7 in Q2A Core by esqeudero


I want to change sub navlink path names in url for following pages:

  • user/wall  (I want to change "wall" to something else, for example "pin")
  • user/activity  (I want to change "activity" to something else)
  • user/questions (I want to change "questions" to something else)
  • user/answers (I want to change "answers" to something else)
  • questions?sort=hot (I want to change "hot" to something else)
  • questions?sort=votes (I want to change "votes" to something else)
  • questions?sort=answers (I want to change "answers" to something else)
  • questions?sort=views (I want to change "views" to something else)

 For this, I changed cases in pages/user.php.(I only show you what changes I have done for case "wall")

// Display the appropriate page based on the request

switch (qa_request_part(2)) {

case 'pin':


$qa_content = include QA_INCLUDE_DIR.'pages/user-wall.php';


 2) I also modified user-wall.php as

// Sub menu for navigation in user pages

$ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']);

$qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'pin', $ismyuser);

return $qa_content;

Now, When I manually type www.mywebsite.com/user/esqeudero/pin the page works fine. However, in user page, the submenu link for wall still appears www.mywebsite.com/user/esqeudero/wall

What I have missed?

Q2A version: 1.7.4

1 Answer

+2 votes
answered Sep 7 by Scott
selected Sep 7 by esqeudero
Best answer

You don't need to modify core files for this. There are 2 things you need to do. First, you can change the name of the menu item in the language settings. See here for the simplest method. For example you'd need to add this in qa-lang-misc.php:

'nav_user_wall' => 'Pin',

Second, use the $QA_CONST_PATH_MAP option in qa-config.php. For example:

    'wall' => 'pin',

Edit: sorry just realized that won't work. You're asking for the wall page for every user I think... so scott/wall, esqeudero/wall etc? It won't work with dynamic URLs. In which case yes the way you've done is currently the only method.

The navigation link you're missing is in the qa_user_sub_navigation function which is in qa-include/app/format.php. In the second bit of code you changed, you only changed the 'selected' menu item (i.e. the one that appears blue). In that function, on the 'wall' key change the URL to have /pin at the end instead of /wall.

You'll need to do similar things for the other user pages. For the questions?sort=X URLs, look for case 'hot': and so on in qa-include/pages/questions.php. There are 2 occurrences of each.

commented Sep 7 by esqeudero
Thank you Scott. I followed you, and modified necessary files. It works.