Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
561 views
in Q2A Core by
edited by

I am currently building a couple of Q&A sites, one of which will feature a StackOverflow-style top bar and main nav.

For this site I am pulling the administration link entirely out of the main navigation menu, and also moving the custom page links from the main nav to the user nav. I do this by finding, copying and unsetting the navigation menus with code like this:

// extract and remove the admin menu link
if(isset($this->content['navigation']['main'])) {
  $this->admin_link = $this->content['navigation']['main']['admin'];
  unset($this->content['navigation']['main']['admin']);
}
 
// move all the 'opposite' links from the main nav to the user nav
foreach($this->content['navigation']['main'] as $k => $v) {
  if(isset($v['opposite']) && ($v['opposite']===true)) {
    $v['opposite'] = false;
    $this->content['navigation']['user'][$k] = $v;
    unset($this->content['navigation']['main'][$k]);
  }
}
 
Is there a neater or more 'official' way to achieve this within a theme or otherwise?

1 Answer

0 votes
by

No, I don't think so. To move items between menus you need to edit at the source when they are put into the appropriate variables, which is in the core code. This can't be changed with a plugin to be knowledge,.

In an advanced theme you could put explicit links in certain places, then hide them from their original place. That would work fairly well and survive Q2A upgrades. The problem here is that if you updated, added or removed a page you'd have to go back to your theme and edit the links again.

...