Difference between revisions of "Template:Main/doc"

m (Fixed the broken link in the 2nd example.)
m (Text replacement - "[[BattleTechWiki:Template messages" to "[[BattleTechWiki:Template index")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly>{{template doc page transcluded}}</includeonly><noinclude>{{template doc page viewed directly}}</noinclude>
+
<noinclude>{{pp-vandalism|small=yes}}</noinclude>{{Documentation subpage}}
<!-- EDIT TEMPLATE DOCUMENTATION BELOW THIS LINE -->
+
{{Never substitute}}
 +
{{Lua|icononly=on|Module:Labelled list hatnote}}
  
==Purpose==
+
{{hatnote|This template is for linking to main content. For the mainspace detection template, see [[:template:main other]].}}
Some articles are broken out from larger articles as a means of conserving space, easing readibility and providing clarity. In those cases, it is proper to link back to the original article from which the subject article is introduced. While behaving similarly to the function of categories, the use of the '''<nowiki>{{main}}</nowiki>''' template is to recognize the direct relationship with an article of broader scope.
 
  
== Usage ==
+
When an article is large, it is often written in [[BattleTechWiki:Summary style|summary style]]. This [[BattleTechWiki:Template index|template]] is used after the heading of the summary, to link to the subtopic article that has been summarized. For [[Help:Category|Category namespace]], please use '''{{tl|Cat main}}''' instead.
To link to a "main article" on a topic, use '''<nowiki>{{main|The other article}}</nowiki>''', replacing 'the other article' with the actual name of the main page.
 
  
==Example==
+
Use of this template should be restricted to the purposes described above. It is '''not''' to be used as a substitute for inline links or {{tl|Further}} template. The latter is used when the section expounds a specific aspect of the topic instead of summarizing its article.
<pre>
 
<nowiki>{{main|Knights of the Inner Sphere}}</nowiki>
 
</pre>
 
Will display:
 
:''Main article: [[Knights of the Inner Sphere]]''
 
  
 +
This template should also not be used in lead sections. A lead section is always a summary of its own article, not any other; as such, the only appropriate target for a {{tl|Main}} link in the lead section would be the article itself, which is not useful.
  
(The example can be seen [[Free Worlds League Military#Knights of the Inner Sphere|here]].)
+
{{TOC limit}}
  
<includeonly>
+
==Usage==
<!-- ADD CATEGORIES BELOW THIS LINE -->
+
{{see|BTW:SUMMARYHATNOTE}}
[[Category:Page Information templates|{{PAGENAME}}]]
+
{{startplainlist}}
[[Category:Templates|{{PAGENAME}}]]
+
* {{vad|Basic usage:|7.5em|left}} <code>{{((}}{{BASEPAGENAME}}{{!}}{{var|page}}{{))}}</code>
[[Category:List templates|Main]]
+
* {{vad|All parameters:|7.5em|left}} <code>{{((}}{{BASEPAGENAME}}{{!}}{{var|page1}}{{!}}{{var|page2}}{{!}}{{var|page3}}{{!}}&nbsp;...&nbsp;{{!}}l1&nbsp;{{=}}&nbsp;{{var|label1}}{{!}}l2&nbsp;{{=}}&nbsp;{{var|label2}}{{!}}l3&nbsp;{{=}}&nbsp;{{var|label3}}{{!}}&nbsp;...&nbsp;{{!}}selfref&nbsp;{{=}}&nbsp;{{var|yes}}{{))}}</code>
</noinclude>
+
{{endplainlist}}
 +
 
 +
==Parameters==
 +
*<code>1</code>, <code>2</code>, <code>3</code>, ... – the pages to link to. If no page names are specified, the current page name is used instead (without the [[BattleTechWiki:Namespace|namespace]] prefix). Categories and files are automatically escaped with the [[Help:Colon trick|colon trick]], and links to sections are automatically formatted as ''page § section'', rather than the MediaWiki default of ''page#section''.
 +
*<code>l1</code>, <code>l2</code>, <code>l3</code>, ... ''or''<code>label 1</code>, <code>label 2</code>, <code>label 3</code>, ... – optional labels for each of the pages to link to (this is for articles where a piped link would be used). Note that the extra parameters use a lower case 'L', for example, <code>l1</code>, <u>not</u> <code>L1</code>.
 +
*<code>selfref</code> – if set to "yes", "y", "true" or "1", adds the CSS class "selfref". This is used to denote self-references to BattleTechWiki. See [[Template:Selfref]] for more information. This is only necessary in articles and other content (e.g. templates) that will appear in articles, and need not be added for uses of this template on <code>BattleTechWiki:</code> namespace pages.
 +
 
 +
==Template data==
 +
{{TemplateData header}}
 +
<templatedata>
 +
{
 +
"description": "This template is used after the heading of a section, to link to a sub-article (or sub-articles) that is entirely about the topic of the section. The template will display, in italics, \"Main article: Article 1, Article 2 and Article 3\"",
 +
"params": {
 +
"1": {
 +
"label": "Page 1",
 +
"description": "The name of the first page that you want to link to. If this is not specified, the current page name (with no namespace prefix) is used instead. ",
 +
"type": "wiki-page-name",
 +
"required": true,
 +
"suggested": true
 +
},
 +
"2": {
 +
"label": "Page 2",
 +
"description": "The name of the second page that you want to link to.",
 +
"type": "wiki-page-name",
 +
"required": false
 +
},
 +
"3": {
 +
"label": "Page 3",
 +
"description": "The name of the third page that you want to link to. More pages can be added using the parameters \"4\", \"5\", etc.",
 +
"type": "wiki-page-name",
 +
"required": false
 +
},
 +
"l1": {
 +
"type": "string",
 +
"label": "Label 1",
 +
"description": "What the first linked page is to be displayed as.",
 +
"aliases": [
 +
"label 1"
 +
]
 +
},
 +
"l2": {
 +
"label": "Label 2",
 +
"description": "What the second linked page is to be displayed as.",
 +
"type": "string",
 +
"aliases": [
 +
"label 2"
 +
]
 +
},
 +
"l3": {
 +
"label": "Label 3",
 +
"description": "What the third linked page is to be displayed as. Other labels can be added by using increasing numbers (starting with \"l4\" for page 4) as parameter names.",
 +
"type": "string",
 +
"aliases": [
 +
"label 3"
 +
]
 +
},
 +
"selfref": {
 +
"type": "boolean",
 +
"label": "Self reference",
 +
"description": "Set to \"yes\" if the template is a self-reference to BattleTechWiki that would not make sense on mirrors or forks of the BattleTechWiki site."
 +
}
 +
},
 +
"paramOrder": [
 +
"1",
 +
"2",
 +
"3",
 +
"l1",
 +
"l2",
 +
"l3",
 +
"selfref"
 +
],
 +
"format": "{{_|_ = _}}\n"
 +
}
 +
</templatedata>
 +
 
 +
==Examples==
 +
{{hatnote|Underscores (_) between words are not necessary}}
 +
*<code><nowiki>{{Main}}</nowiki></code> &rarr; {{main|category=no}}
 +
*<code><nowiki>{{Main|Article}}</nowiki></code> &rarr; {{main|Article}}
 +
*<code><nowiki>{{Main|Article#Section title}}</nowiki></code> &rarr; {{main|Article#Section title}}
 +
*<code><nowiki>{{Main|Article#Section|l1=Custom section label}}</nowiki></code> &rarr; {{main|Article#Section|l1=Custom section label}}
 +
*<code><nowiki>{{Main|Article1|Article2|Article3}}</nowiki></code> &rarr; {{main|Article1|Article2|Article3}}
 +
*<code><nowiki>{{Main|Article1|l1=Custom label 1|Article2|l2=Custom label 2}}</nowiki></code> &rarr; {{main|Article1|l1=Custom label 1|Article2|l2=Custom label 2}}
 +
 
 +
==Errors==
 +
If the name of the first page that you want to link to is not specified, the current page name (with no namespace prefix) is used instead:
 +
*{{Main|category=no}}
 +
 
 +
No errors can be displayed due to the illegal usage of parameters or other usages (i.e. the first parameter can be omitted, other parameters can be used even if the first one is empty (and automatically filled with the current page name (with no namespace prefix)), equals sign can be used as one of the parameters, and template can be used by direct call to the module (using "#invoke")). This is not the case for {{tl|see also}}, for example.
 +
 
 +
==See also==
 +
*{{tl|Main list}}: For a more comprehensive list, see {{color|blue|Article}}.
 +
*{{tl|Broader}}: For broader coverage of this topic, see {{color|blue|Article}}.
 +
*{{tl|Excerpt}}, which allows transclusion of text (such as an intro section) from one article into another
 +
*{{tl|Further}}: Further information: {{color|blue|Article}}.
 +
{{Hatnote templates}}
 +
<includeonly>{{sandbox other||
 +
<!-- Categories go here and interwikis go in Wikidata. -->
 +
[[Category:Hatnote templates]]
 +
[[Category:Page-section templates]]
 +
 
 +
}}</includeonly>

Latest revision as of 21:57, 2 April 2024

When an article is large, it is often written in summary style. This template is used after the heading of the summary, to link to the subtopic article that has been summarized. For Category namespace, please use {{Cat main}} instead.

Use of this template should be restricted to the purposes described above. It is not to be used as a substitute for inline links or {{Further}} template. The latter is used when the section expounds a specific aspect of the topic instead of summarizing its article.

This template should also not be used in lead sections. A lead section is always a summary of its own article, not any other; as such, the only appropriate target for a {{Main}} link in the lead section would be the article itself, which is not useful.

Usage[edit]

  • Basic usage: {{Main|page}}
  • All parameters: {{Main|page1|page2|page3| ... |l1 = label1|l2 = label2|l3 = label3| ... |selfref = yes}}

Parameters[edit]

  • 1, 2, 3, ... – the pages to link to. If no page names are specified, the current page name is used instead (without the namespace prefix). Categories and files are automatically escaped with the colon trick, and links to sections are automatically formatted as page § section, rather than the MediaWiki default of page#section.
  • l1, l2, l3, ... orlabel 1, label 2, label 3, ... – optional labels for each of the pages to link to (this is for articles where a piped link would be used). Note that the extra parameters use a lower case 'L', for example, l1, not L1.
  • selfref – if set to "yes", "y", "true" or "1", adds the CSS class "selfref". This is used to denote self-references to BattleTechWiki. See Template:Selfref for more information. This is only necessary in articles and other content (e.g. templates) that will appear in articles, and need not be added for uses of this template on BattleTechWiki: namespace pages.

Template data[edit]

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools.

TemplateData for Main

This template is used after the heading of a section, to link to a sub-article (or sub-articles) that is entirely about the topic of the section. The template will display, in italics, "Main article: Article 1, Article 2 and Article 3"

Template parameters

This template has custom formatting.

ParameterDescriptionTypeStatus
Page 11

The name of the first page that you want to link to. If this is not specified, the current page name (with no namespace prefix) is used instead.

Pagerequired
Page 22

The name of the second page that you want to link to.

Pageoptional
Page 33

The name of the third page that you want to link to. More pages can be added using the parameters "4", "5", etc.

Pageoptional
Label 1l1 label 1

What the first linked page is to be displayed as.

Stringoptional
Label 2l2 label 2

What the second linked page is to be displayed as.

Stringoptional
Label 3l3 label 3

What the third linked page is to be displayed as. Other labels can be added by using increasing numbers (starting with "l4" for page 4) as parameter names.

Stringoptional
Self referenceselfref

Set to "yes" if the template is a self-reference to BattleTechWiki that would not make sense on mirrors or forks of the BattleTechWiki site.

Booleanoptional

Examples[edit]

Errors[edit]

If the name of the first page that you want to link to is not specified, the current page name (with no namespace prefix) is used instead:

  • Error: no page names specified (help).

No errors can be displayed due to the illegal usage of parameters or other usages (i.e. the first parameter can be omitted, other parameters can be used even if the first one is empty (and automatically filled with the current page name (with no namespace prefix)), equals sign can be used as one of the parameters, and template can be used by direct call to the module (using "#invoke")). This is not the case for {{see also}}, for example.

See also[edit]

  • {{Main list}}: For a more comprehensive list, see Article.
  • {{Broader}}: For broader coverage of this topic, see Article.
  • {{Excerpt}}, which allows transclusion of text (such as an intro section) from one article into another
  • {{Further}}: Further information: Article.