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

Hi,

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_set_template('user-wall');

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

break;

 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
by
selected by
 
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:

$QA_CONST_PATH_MAP = array(
    '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.

by
Thank you Scott. I followed you, and modified necessary files. It works.
...