Template:MenuEntry
This documentation is for {{MenuEntry}}, {{MenuEntryAlternative}}, {{SubMenuEntry}}, and {{SubMenuEntryAlternative}}.
These templates generate an entry for the menus listed at the top on every page.
Structure
The structure of a new template is
{{MenuStart}} {{MenuEntryAlternative|Highlight1|Link1|Caption1|class=lang_main}} {{MenuEntry|Highlight2|Link2|Caption2}} </ul></div><noinclude>{{documentation|Template:TopMenu/doc}}</noinclude>
Depending on the level (Main or sub level) the MenuStart template has to be replaced with SubMenuStart.
Parameters
The following table contains a matrix of supported features of the different templates.
Template name \ Parameter Name (short description) | {{{1}}} (highlight search string) | {{{2}}} (link) | {{{3}}} (caption) | {{{class}}} | {{{background}}} | {{{color}}} | {{{parameter}}} | {{{highlight}}} |
---|---|---|---|---|---|---|---|---|
{{MenuEntry}} | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
{{MenuEntryAlternative}} | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
{{SubMenuEntry}} | Yes | Yes | Yes | Yes | Yes | Yes | No | No |
{{SubMenuEntryAlternative}} | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
The class parameter is used and needed for the very first list element to provide a CSS style sheet. Until now every menu template uses the class="lang_main" style sheet.
The parameter background and color (text color) are predefined, but can be overwritten per template basis (or for creating a new meta/wrapper template).
The |parameter= is used for the part of the path which is checked for the highlight, so e.g. for the path Development/EasyHacks parameter=3 is needed to highlight the caption (and parameter |1=Completed) instead of the default value.
The parameter |highlight has only two values at the moment:
- fullpagename - to use the full article path when checking for the highlight, and
- the default value (everything other than fullpagename) - so checking against a certain part of the path (without namespace)
Template name \ Parameter Name (short description) | {{{style}}} | {{{background}}} | {{{solid}}} | {{{lang}}} | {{{dir}}} |
---|---|---|---|---|---|
{{MenuStart}} | Yes | Yes | Yes | Yes | Yes |
{{SubMenuStart}} | Yes | No | No | Yes | No |
Examples and Tips&Tricks
a few simple examples
{{Menu/es}} includes a link to the Spanish Design start page. As you can see on this very simple example, the caption is Diseño, the actual link goes to Design/es and Design is checked if the link should be highlighted.
{{MenuEntry|Design|Design/es|Diseño}}
{{Menu.Design}} includes a menu entry for Blueprints. The word Blueprints is in the path at the second level which is the default check using SubMenuEntryAlternative.
{{SubMenuEntryAlternative|Blueprints|Design/Blueprints|Development Blueprints}}
A third example at {{Menu.Extensions}} shows the usage of parameter parameter.
{{SubMenuEntryAlternative|install extension|Documentation/HowTo/install extension|How to: Install an extension|parameter=3}}
RTL languages
{{Menu/ar}} is the Arabic version of {{Menu}}. The template MenuStart and the very first MenuEntry templates has to be using the parameters dir, style, lang and class as showing the following example for Tight-to-Left templates.
{{MenuStart|dir=rtl|style=unicode-bidi: embed;|lang=ar}} {{MenuEntry|Main Page|Main Page/ar|الرئيسية|class=lang_main" dir="rtl}}
Highlighting pages with whitespaces/underscore
Because of MediaWikis internal structure underscores always get translated to whitespaces, although normal wikilinks e.g. Extensions Repository and Extensions_Repository do both work.
When highlighting pages with a whitespace/underscore in the name the first parameter needs testing against whitespaces instead of underscores. See the following example of template {{Menu.Extensions}}:
{{SubMenuEntry|Extensions Repository|Extensions Repository|Repository}}
multiple pages with the same highlight
{{Menu.Extensions}} includes two pages with the name "Extensions" on the last directory. To not highlight both pages you could use (in this example) two different solutions:
{{SubMenuEntryAlternative|Extensions|Extensions|Extensions|class=lang_main|parameter=1}} {{SubMenuEntryAlternative|QA|QA/BugReport/Extensions|How to: report a bug|parameter=1}}
or
{{SubMenuEntryAlternative|Extensions|Extensions|Extensions|class=lang_main|highlight=fullpagename}} {{SubMenuEntryAlternative|QA/BugReport/Extensions|QA/BugReport/Extensions|How to: report a bug|highlight=fullpagename}}or of course any combination of the above two examples.