How do I add a horizontal top menu bar to a MediaW

2019-06-07 00:55发布

问题:

I want my MediaWiki site to have (either in addition to, or instead of, the sidebar) a bar of links at the top of the site, visible on every page.

Requirements

To minimize future maintenance burden, my requirements are:

  1. No modifications to core, extension or skin code. I do not want to maintain project forks.

  2. Ideally, privileged users should be able to edit the links shown in the menu bar by editing a special page, similar to how MediaWiki:Sidebar controls the content of the usual sidebar.

Solutions I have tried

  • The Topbar extension looks like an ideal solution, but it does not seem to work with the latest MediaWiki versions (see my SO question #37423269 for details if interested).

  • The MegaMenu extension looks awesome, but has an invasive installation procedure which violates my requirement #1 above. It also requires editing a PHP file to change the links, which violates #2.

  • The Erudite skin is beautiful, with built-in support for a top menu bar. But in my test, the top menu bar area was empty, and the sidebar was rendered at the very bottom of the page in the footer. The skin documentation does not explain how to customize the top menu bar content.

Is there something obvious I am overlooking here? How do other MediaWiki sites do this?

回答1:

After digging further into the Erudite skin, I learned that its horizontal top menu bar is drawn from the "navigation" section of the MediaWiki:Sidebar. (My particular problem was that I had that section labeled capitalized as "Navigation" rather than all lower case as "navigation"; when I changed that, I started seeing links in the top menu.)

So with that skin, the sidebar might look something like:

* navigation
** Welcome|Welcome
** Downloads|Downloads
** Help|Contact and Help

* Learn
** Introduction|Introduction
** User Guides|User Guides
** Tutorials|Tutorials

* Develop
** Development|Overview
** Scripting|Scripting
** Source code|Source code

And the menu will render similar to:

I'd still be interested to hear if I am missing some built-in MediaWiki functionality, e.g. with the Vector skin, or a common widely used extension.