Community Central

READ MORE

Community Central
Community Central
Community Central
Sandbox
This is a user sandbox page owned by Oot42.
A user sandbox is a subpage of the user's userpage that serves as a testing and development playground.
Note that the content of this page may be deleted or overwritten at any time. If you want to bookmark or link to this page in its current state, copy the URL from "Permanent link" found in the side rail's Page Tools. You can also find older revisions in the sandbox log.

Template: subpage multitab (v1.1)

Note: This is an updated version of this template. The original version is here.
If there should be an even newer version, you can find it here.

Instructions

1) Make a new template → Template:Subpage multitab

Code:        (copy/paste)
<includeonly><div class="subpage-tab subpage-multitab">{{#ifeq:
{{SUBPAGENAME}}|{{PAGENAME}}|<span class="subpage-tab-active">{{{1|{{{tab1}}}}}}</span>|<span>[[{{ROOTPAGENAME}}|{{{1|{{{tab1}}}}}}]]</span>}}{{#if:
{{{2|{{{tab2|}}}}}} | {{Subpage multitab/tabs|{{{2|{{{tab2|}}}}}}}} }}{{#if:
{{{3|{{{tab3|}}}}}} | {{Subpage multitab/tabs|{{{3|{{{tab3|}}}}}}}} }}{{#if:
{{{4|{{{tab4|}}}}}} | {{Subpage multitab/tabs|{{{4|{{{tab4|}}}}}}}} }}{{#if:
{{{5|{{{tab5|}}}}}} | {{Subpage multitab/tabs|{{{5|{{{tab5|}}}}}}}} }}</div></includeonly><noinclude>
{{Documentation}}</noinclude>


2) Make a subtemplate → Template:Subpage multitab/tabs

Code:        (copy/paste)
{{#ifeq:{{SUBPAGENAME}}|{{#if:{{#pos:{{{1}}}|;}}|{{#explode:{{{1}}}|;|1}}|{{{1}}}}}|<span class="subpage-tab-active">{{#explode:{{{1}}}|;}}</span>|<span>[[{{ROOTPAGENAME}}/{{#if:{{#pos:{{{1}}}|;}}|{{#explode:{{{1}}}|;|1}}|{{{1}}}}}|{{#explode:{{{1}}}|;}}]]</span>}}<noinclude>
----
;Description
:This is a helper subtemplate of {{t|Subpage multitab}}.
:It is used to create the additional tabs.

:Read the main template's documentation for further infos.
</noinclude>


3) Make a template subpage for the documentation → Template:Subpage multitab/doc

Code:        (copy/paste)
{{tocright}}
===Description===
:Template to create a multi-tabbed layout for subpages.

===Syntax===
:<code><nowiki>{{Subpage multitab|<tab1>|<tab2>| [...] |<tab5>}}</nowiki></code>

;Alternative notation
<pre>{{Subpage multitab
|tab1 = 
|tab2 = 
|tab3 = 
|tab4 = 
|tab5 = 
}}</pre>

====Parameter====
{| class="wikitable"
|- style="vertical-align:top;"
| <code>1</code> or<br><code>tab1</code> || Name of the main page tab.<br>This is the name to be displayed, not the pagename.
|- style="vertical-align:top;"
| <code>2</code> or<br><code>tab2</code> || Name of the 2nd tab.<br>This is the name to be displayed and by default assumes to be the subpage-name as well.
;Option
:In case the tabs should have different names displayed than the names of the subpages, this can be done by dividing it with a semicolon <code>;</code> in the parameter.
:Example: <code><tabname>;<subpagename></code>
:This does ''not'' apply for the mainpage tab (tab1) !
|- style="vertical-align:top;"
| <code>3</code> - <code>5</code> or<br><code>tab3</code> - <code>tab5</code> || Optional additional tabs.<br>Same conditions as for 2 above.
|}

===Example usage===
:Layout for 3 tabs: main page, cast, gallery
:# Create subpages named "/Cast" and "/Gallery"
:# Put this on top of the mainpage and of all subpages:<br><code><nowiki>{{Subpage multitab|Overview|Cast|Gallery}}</nowiki></code>
:# That's all.

:Example if tab-names and subpage-names would be different:
:<code><nowiki>{{Subpage multitab|Overview|Cast;cast-list|Gallery;image gallery}}</nowiki></code>

===Limitations===
:Prepared for 5 tabs (main page + 4)
:More tabs can be added by adding more lines of this code right before the closing <nowiki></div></nowiki>: (counting up all numbers in it)
<pre>{{#if:
{{{6|{{{tab6|}}}}}} | {{Subpage multitab/tabs|{{{6|{{{tab6|}}}}}}}} }}</pre>

===Dependencies===
:Uses a subtemplate {{t|Subpage multitab/tabs}}
:Needs [[MediaWiki:Common.css|custom css]] for styling.

===Release notes===
:2024-04-10 | v1.0 | Coded by [[w:User:Oot42|Oot42]]
:2024-04-11 ! v1.1 ! Update to allow different names for tabs and subpages

__NOEDITSECTION__
<includeonly>[[Category:Article design templates|{{PAGENAME}}]][[Category:Tab templates|{{PAGENAME}}]]</includeonly>
<noinclude>[[Category:Template documentation|{{PAGENAME}}]]</noinclude>
Note: You may want to change the categories on the second to last line in the doc (these apply to the template).


4) CSS → MediaWiki:Common.css / MediaWiki:FandomMobile.css

Code:        (copy/paste)
/* Styles for template 'subpage tab' & 'subpage multitab' */
.subpage-tab {
  width:100%;
  border-bottom:1px solid var(--theme-border-color);
  margin-bottom:2em;
  padding-bottom:5px;
}
.subpage-tab span:first-of-type,
.subpage-multitab span:not(:last-of-type) {
  margin-right:25px;
}
.subpage-tab .subpage-tab-active {
  border-bottom:3px solid;
  padding-bottom:7px;
}
.subpage-tab a {
  text-decoration:none;
}


See also