Extension:Header Tabs

From MediaWiki.org
(Redirected from Header Tabs)
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
Header Tabs

Release status: stable

Implementation Parser function, User interface
Description Displays top-level headers as JavaScript-based tabs
Author(s) Sergey Chernyshev, Yaron Koren
Latest version 1.0.1 (July 2014)
MediaWiki 1.17 or greater
Database changes No
License GPL
Download
Version history
Example Wiki of the Month on semantic-mediawiki.org
Parameters

Configuration section

Translate the Header Tabs extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

The Header Tabs extension transforms top-level MediaWiki headers into tabs using the jQuery UI JavaScript library.

Usage[edit | edit source]

To enable tabs on a page after you installed the extension, you need to add a

<headertabs />

tag into the page in place where the last tab should end (everything below this tag will be shown under the tab view). Most of the time, though, you'll want to put it at the bottom of the page.

In addition to that, the page should have top-level headers defined in it like this:

= Header title =

Each such top-level header, if it's anywhere above the <headertabs/> tag, will be displayed as a tab.

Linking to tabs[edit | edit source]

You can link to a tab, both from another page and from within that same page (and, within that same page, both from another tab and from outside the tab view). This is done using the {{#switchtablink}} parser function, which is called like this:

{{#switchtablink:Tab name|Link text|Page name}}

This will create a link to the tab with the name "Tab name", and the text of the link will read "Link text". If you want the link to a point to a tab on another page, you can optionally add the third parameter, "Page name".

Example[edit | edit source]

Some text above the tab view
= First section header =
This will be displayed on the first tab

{{#switchtablink:Second section header|Click here to go to the next tab...}}

= Second section header =
This will be displayed on the second tab
<headertabs/>
= Third section header =
This will be always displayed under the tab view
because it's below the <headertabs/> tag.

The header titles get automatically converted into tab titles.

Download[edit | edit source]

You can download the Header Tabs code, in .zip format, here.

You can also download the code directly via Git from the MediaWiki source code repository. From a command line, call the following:

git clone https://git.wikimedia.org/git/mediawiki/extensions/HeaderTabs.git

To view the code online, including the version history for each file, go here.

Installation[edit | edit source]

  • Download and extract the file(s) in a directory called HeaderTabs in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository using:
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/HeaderTabs.git
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/HeaderTabs/HeaderTabs.php";
  • Modify and configure as described in the following section
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Modifications[edit | edit source]

Skin modification[edit | edit source]

To change the tabs' styling, see "Skin modification".

Configuration parameters[edit | edit source]

The following parameters can be modified in LocalSettings.php below the require_once(...).

$htUseHistory[edit | edit source]

$htUseHistory defines whether tab navigation should be tracked within the browser history and within the URL, updating the hash value. By default this variable is set to true, i.e. history is used. You can disable it by adding the following:

$htUseHistory = false;

$htRenderSingleTab[edit | edit source]

The $htRenderSingleTab variable defines if Header Tabs will activate if only a single top-level header is found. By default this variable is set to false, i.e. no tabs will be shown if only one top-level header is found. You can enable this behaviour by adding the following:

$htRenderSingleTab = true;

$htAutomaticNamespaces[edit | edit source]

The $htAutomaticNamespaces variable defines the set of namespaces for which you don't need to add the <headertabs /> tag in order to enable tabs. If a namespace ID is defined in this variable, header tabs will activate automatically when you have two top-level headers (or one, if you have $htRenderSingleTab set to true) in an article. By default this variable holds no namespaces. You can add namespaces to this list by adding the following for each namespace:

$htAutomaticNamespaces[] = NS_MAIN;

$htDefaultFirstTab[edit | edit source]

The $htDefaultFirstTab variable defines whether Header Tabs puts any content before the first defined header and put it into its own tab. By default this variable is set to false. You can enable this behavior by adding the default name using the following:

$htDefaultFirstTab = 'DefaultTabName';

If using this setting, be careful not to enable $htRenderSingleTab as it will lead to tabs appearing in other parts of the UI.

$htDisableDefaultToc[edit | edit source]

The $htDisableDefaultToc variable defines whether Header Tabs will disable the MediaWiki article's table of contents (TOC) when tabs are enabled for a given article. This saves you the trouble of having to add __NOTOC__ to your article. If tabs are not enabled because of a lack of top-level headers, the table of contents will appear as usual. By default this variable is set to true, i.e. the MediaWiki TOC is disabled if header tabs are shown. You can disable this behavior by adding the following:

$htDisableDefaultToc = false;

$htGenerateTabTocs[edit | edit source]

The $htGenerateTabTocs variable defines if Header Tabs will try to generate a TOC for each tab. By default this variable is set to false, i.e. no tab TOCs will be generated. You can enable this behavior by adding the following:

$htGenerateTabTocs = true;

$htEditTabLink[edit | edit source]

The $htEditTabLink variable defines if Header Tabs will add a edit link to the right of the tabs which let you edit only the tabs' text. By default this variable is set to true, i.e. a edit link for the tab will be shown. You can disable this behavior by adding the following:

$htEditTabLink = false;

$htStyle[edit | edit source]

The $htStyle variable defines what visual style is used for the tabs. By default this variable is set to 'large'. You can change the style by adding the following:

$htStyle = 'style-name';

Styles included with the extension are:

Name Description Screenshot
jquery The basic styling provided by MediaWiki - it makes text smaller and links black.
large The default style. It makes the text normal-size and turns links blue (or red) again.
bare Similar formatting to the "large" style, but without most of the borders and background colors, so that the only real change to the page is the tabs themselves.

A wider selection of user-made styles as well as information about how to create your own styles is on our /Skin modification page.

Version history[edit | edit source]

To see a list of changes for each version, see version history. For a list of features planned for future releases, please see roadmap.

Known limitations and issues[edit | edit source]

  • You cannot use the tag more than once. In other words, a second tag will not produce a second series of tabs.
  • Tabs render on top of infoboxes in Chrome.

Incompatible extensions[edit | edit source]

Header Tabs does not seem to work when used alongside the following extensions:

  • MathJax - when the two are used together, it leads to faulty HTML, which results in a broken display in at least the Firefox web browser. (Things might have changed as MathJax has been updated.) You can disable MathJax on specific pages by adding __NOMATHJAX__.
  • AddThis (or the Widget or WidgetsFramework versions) - only the first tab is shown with Firefox, and no icons are shown with Safari.
  • FancyBoxThumbs - same as AddThis.
  • MobileFrontend.
  • SectionHide - incompatible due to both extensions altering section behavior. SectionHide now includes an automatic check that will inform the user that the extension does not work with Header Tabs.
  • The now-defunct UsabilityInitiative, due to a jQuery conflict.

Sites using this extension[edit | edit source]

See here for a list of wikis. If you use this extension, please add a link to your wiki at the bottom of this list.

Support[edit | edit source]

The best way to seek help with this extension is to send questions the to mediawiki-l mailing list. The extension maintainers, and active users and contributors, are on this list and will be able to help you.

See also[edit | edit source]