Template:Tabs flexible

From OpenStreetMap Wiki
Jump to navigation Jump to search

Sample content


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

This was copied from User:MarkS/Tabs, modified its design to fit JOSM/Guide, simplified parameters by nazotoko and switched from using a wiki table to using CSS flexbox by Chris2map under new name Template:Tabs flexible for improving usability on small screens like mobile devices.

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.

This template is used e.g. in Template:HelpMenu.

The template can support up to 10 tabs — the actual number depends on the number of tabs defined in the parameters for the template.

Each tab is allocated a proportional width according to its content.

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.
10 Optional The actual page name (or URL) for tab 10. If 10 is not supplied then tab number 10 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).
tab-height Optional ???px (default is "12px"). To adjust the white space above and below the tab label text, increasing or decreasing the height of the tabs.
bgcolor Optional colour code (default is "#EEF"). To change the colour of the (inactive) tabs.

Note: Parameters 1 to 10 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.

TemplateData

This is the TemplateData for this template used by VisualEditor.
TemplateData for Tabs flexible

Displays tabs that act as links to different pages, allowing for convenient switching between them.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Link 11

The actual page name (or URL) to link for tab 1.

Example
Get help
Stringrequired
Link 22

The actual page name (or URL) to link for tab 2.

Example
About
Stringsuggested
Link 33

The actual page name (or URL) to link for tab 3.

Stringoptional
Link 44

The actual page name (or URL) to link for tab 4.

Stringoptional
Link 55

The actual page name (or URL) to link for tab 5.

Stringoptional
Link 66

The actual page name (or URL) to link for tab 6.

Stringoptional
Link 77

The actual page name (or URL) to link for tab 7.

Stringoptional
Link 88

The actual page name (or URL) to link for tab 8.

Stringoptional
Link 99

The actual page name (or URL) to link for tab 9.

Stringoptional
Link 1010

The actual page name (or URL) to link for tab 10.

Stringoptional
Label 1label1

The label for tab 1 instead of the page name.

Linesuggested
Label 2label2

The label for tab 2 instead of the page name.

Linesuggested
Label 3label3

The label for tab 3 instead of the page name.

Lineoptional
Label 4label4

The label for tab 4 instead of the page name.

Lineoptional
Label 5label5

The label for tab 5 instead of the page name.

Lineoptional
Label 6label6

The label for tab 6 instead of the page name.

Lineoptional
Label 7label7

The label for tab 7 instead of the page name.

Lineoptional
Label 8label8

The label for tab 8 instead of the page name.

Lineoptional
Label 9label9

The label for tab 9 instead of the page name.

Lineoptional
Label 10label10

The label for tab 10 instead of the page name.

Lineoptional
Selected tabselected

Normally, this parameter is not required. You can use it to define the selected tab manually. 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. Default value is the page name using this template.

Lineoptional
Edit linkedit

The full page name containing the list of tabs. (Generates a small link at end of tabs to editing them.)

Example
Template:Name of menu template page
Page nameoptional
no_bottom_borderno_bottom_border

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).

Auto value
yes
Lineoptional
Tab heighttab-height

Changes default height of the tabs.

Default
12px
Example
8px
Lineoptional
Tab colourbgcolor

Changes default colour of the (inactive) tabs.

Default
#EEF
Example
#eee
Lineoptional

Using the template

In short: {{Tabs flexible|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.

But 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 flexible|JOSM|JOSM/Plugins|JOSM/Guide|
label1=Introduction|
label2=Plugins|
selected=JOSM/Plugins
}}
(contents)
</div> <!-- This template opens a <div> but doesn't close it. If you don't close it with a </div>, 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 flexible
| 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 ...
</div>
... out of the tab page ...

gives:

context

  • item 1
  • item 2
inside table yes

... out of the tab page ...

Example 2

{{Tabs flexible
| 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
}}
</div>
context
* item 1
* item 2
... some contents displayed out of the ''Template:Tabs flexible''.

gives:

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