Template:Tabs

From OpenStreetMap Wiki
Jump to navigation Jump to search
Template:Tabs Template:Tabs/doc The Map

Sample content

[Edit] [Purge] Template-info.svg Template documentation

This was copied from User:MarkS/Tabs, modified its design to fit JOSM/Guide and simplified parameters by nazotoko.

This is a template to allow users to add a set of tabs at the top of a page to switch between different pages. It is based on the code used on DE:JOSM/Guide converted to template form for easy inclusion on other pages.

The template can support up to 9 tabs — the actual number depends on the number of tabs defined in the parameters for the template. Whilst the template can allow for upto 9 tabs you should aim to use as few tabs as possible and to have as short as possible text on each tab to ensure that the tabs fit across the page on smaller monitors.

Each tab is allocated a proportional width according to its content. Only one row of tabs is supported, there's no support for wrapping taps in several rows if they can't fit in the display width; if this width is too narrow for the text the text in all tabs will wrap within the tab (all tabs will have their vertical size updated simultaneously).

Parameters

Parameter name Required? Purpose
1 Mandatory The actual page name (or URL) to link for tab 1.
2 Optional The actual page name (or URL) for tab 2. If 2 is not supplied then tab number 2 will not be displayed.
3 Optional The actual page name (or URL) for tab 3. If 3 is not supplied then tab number 3 will not be displayed.
4 Optional The actual page name (or URL) for tab 4. If 4 is not supplied then tab number 4 will not be displayed.
5 Optional The actual page name (or URL) for tab 5. If 5 is not supplied then tab number 5 will not be displayed.
6 Optional The actual page name (or URL) for tab 6. If 6 is not supplied then tab number 6 will not be displayed.
7 Optional The actual page name (or URL) for tab 7. If 7 is not supplied then tab number 7 will not be displayed.
8 Optional The actual page name (or URL) for tab 8. If 8 is not supplied then tab number 8 will not be displayed.
9 Optional The actual page name (or URL) for tab 9. If 9 is not supplied then tab number 9 will not be displayed.
label1 Optional The label for tab 1 instead of the page name. The default is to use the 1 value.
label2 Optional The label for tab 2 instead of the page name. The default is to use the 2 value.
selected Optional The selected tab. May be either an integer which then selects the appropriate tab or a text value in which case it selects the tab showing the text. Using a text value may be easier as it allows swapping the order of tabs without having to update the selected number for each page. Default value is the page name using this template.:{{FULLPAGENAME}}
edit Optional The full page name containing the list of tabs (generates a small link at end of tabs to editing them)
no_bottom_border Optional yes/leave empty. In case of yes, at the end of content there would be no border. Suitable when you close table immediately before content (as a workaround for visual editor to work).

Note: parameters 1 to 9 may now also specify an external URL (autodetected when it contains "//"; any URL scheme supported by this wiki for external links may be specified explicitly, such as "http://" or "https://" and they must follow the accepted community rules: spamming irrelevant URLs via this template is not acceptable, just like they are not acceptable in any wiki page). Their associated labels should be supplied, otherwise the link will only be shown as a number within square brackets (the URL itself will not be shown, except in tooltip when hovering it). This external link is also marked by displaying the standard icon for URLs.

Examples

{{Tabs|London|B|C|D|E| label1=A| selected=E}}

This creates 5 tabs. The 5th tab, of which page name is "E", will be selected. The first tab will be labeled A and will contain a link to London. The second tab will be labeled B and contain a link to B.

Using the template

You will need to repeat the tabs template at the top of each page which is accessed using the tabs.

This can make maintenance a burden. Instead it may be easier to create a second template which accesses this template and supplies all the necessary titles in one go. For example you could create a template called "JOSMTabs" with the following content:


{{Tabs|JOSM|JOSM/Plugins|JOSM/Guide|
label1=Introduction|
label2=Plugins|
selected=JOSM/Plugins
}}
(contents)
|}<!-- This template opens a table but doesn't close it. If you don't close it, it will extend up to the end of the page and will close automatically. -->
out of the tab page

This will create a template that adds 3 tabs to the page with defined headings. To use the template simply include {{JOSMTabs}} on each page you want the tabs to appear on.

Examples

Example 1

{{Tabs
| selected = JOSM/Plugins
| 1 = JOSM | label1 = Introduction
| 2 = JOSM/Plugins | label2 = Plugins
| 3 = JOSM/Guide
| 4 = //josm.openstreetmap.de/ | label4 = JOSM website
}}
... some contents displayed within the tab ...
|}
... out of the tab page ...

gives:

Introduction Plugins JOSM/Guide JOSM website

context

  • item 1
  • item 2
inside table yes

... out of the tab page ...

Example 2

{{Tabs
| selected = JOSM/Plugins | no_bottom_border = yes 
| 1 = JOSM | label1 = Introduction
| 2 = JOSM/Plugins | label2 = Plugins
| 3 = JOSM/Guide
| 4 = //josm.openstreetmap.de/ | label4 = JOSM website
}}
|}
context
* item 1
* item 2
... some contents displayed out of the ''Template:Tabs''.

gives:

Introduction Plugins JOSM/Guide JOSM website

context

  • item 1
  • item 2

... some contents displayed out of the tab. In fact, now Tabs template acts as a separate navigation bar.


See also