Difference between revisions of "Template:Main/doc"

From blackwiki
Jump to navigation Jump to search
test>Nihiltres
test>Fgnievinski
(Template:Broader may be appropriate in lead sections.)
Line 1: Line 1:
This module produces a link to a main article or articles. It implements the {{tl|main}} template. Normally, it produces a link like "Main article: A". If used in the [[Help:Category|category]] namespace, it produces a link like "The main article for this category is A". It is possible to specify multiple articles, and in this case plural wording is used automatically. If the first link is not an article, the module uses the wording "Main page" instead of "Main article".
+
{{Lua|icononly=on|Module:Main}}
  
== Usage from wikitext ==
+
When a [[Wikipedia:What is an article|Wikipedia article]] is large, it is often written in [[Wikipedia:summary style|summary style]]. This [[Wikipedia:Template messages|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.
  
This module cannot be accessed directly from #invoke. Instead, it can only be used through the {{tl|main}} template. Please see the template page for documentation.
+
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. For example, in [[phthalate]], the template under the "Endocrine disruptor" section should '''not''' be {{tlf|Main|Endocrine disruptor}}, because the section specifically deals with phthalate as an endocrine disruptor and not endocrine disruptors in general.
  
== Usage from other Lua modules ==
+
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 article}} link in the lead section would be the article itself, which is not useful. {{tl|Broader}} may be appropriate in this case.
  
Load the module:
+
{{TOC limit}}
  
<source lang="lua">
+
== Usage ==
local mMain = require('Module:Main')
+
; Basic usage: {{tlf|main article|''page''}}
</source>
+
; All parameters: {{((}}main article | ''page1'' | ''page2'' | ''page3'' | ...  | l1 = ''label1'' | l2 = ''label2'' | l3 = ''label3'' | ... | selfref = ''yes''{{))}}
  
You can then use the _main function like this:
+
== Parameters ==
  
<source lang="lua">
+
* <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 [[WP:NS|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''.
mMain._main(options, ...)
+
* <code>l1</code>, <code>l2</code>, <code>l3</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>label 1</code>, <code>label 2</code>, <code>label 3</code>, ... for this template does ''not'' work)
</source>
+
* <code>selfref</code> - if set to "yes", "y", "true" or "1", adds the CSS class "selfref". This is used to denote self-references to Wikipedia. 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>Wikipedia:</code> namespace pages.
  
The parameters following <var>options</var> are a list of link/display tables, used to generate the links. The first value in each table is the link, and is required. The second value in each table is the display value, and is optional. Category or file links are automatically escaped using the [[Help:Colon trick|colon trick]]. If a link includes a section name, and no display value is set, links are automatically formatted as ''page § section'', rather than the MediaWiki default of ''page#section''.
+
== Examples ==
 +
* <code><nowiki>{{main article}}</nowiki></code> &rarr; {{main}}
 +
* <code><nowiki>{{main article|Article}}</nowiki></code> &rarr; {{main|Article}}
 +
* <code><nowiki>{{main article|Article#Section}}</nowiki></code> &rarr; {{main|Article#Section}}
 +
* <code><nowiki>{{main article|Article#Section|l1=Custom section label}}</nowiki></code> &rarr; {{main|Article#Section|l1=Custom section label}}
 +
* <code><nowiki>{{main article|Article1|Article2|Article3}}</nowiki></code> &rarr; {{main|Article1|Article2|Article3}}
 +
* <code><nowiki>{{main article|Article1|l1=Custom label 1|Article2|l2=Custom label 2}}</nowiki></code> &rarr; {{main|Article1|l1=Custom label 1|Article2|l2=Custom label 2}}
 +
* <code><nowiki>{{main article|(15760) 1992 QB1|l1={{mp|(15760) 1992 QB|1}}}}</nowiki></code> &rarr; {{main|(15760) 1992 QB1|l1={{mp|(15760) 1992 QB|1}}}}
  
The <var>options</var> table can be used to configure the function's output. At current, the only option available is "selfref", which is used when the output is a self-reference to Wikipedia. to set this option, use {{code|1={selfref = true}|2=lua}}. (See the {{tl|selfref}} template for more details on self-references.)
+
== 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}}
  
=== Example 1 ===
+
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 case for {{tl|see also}}, for example.
<source lang="lua">
 
mMain._main(nil, {'A'})
 
</source>
 
  
Produces:
+
{{Hatnote templates}}
 
+
{{Collapse top|TemplateData}}
<code><nowiki><div role="note" class="hatnote relarticle mainarticle">Main article: [[A]]</div></nowiki></code>
+
{{TemplateDataHeader}}
 
+
<templatedata>
Displays as:
+
{
 
+
"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\"",
{{main|A}}
+
"params": {
 
+
"1": {
=== Example 2 ===
+
"label": "Page 1",
<source lang="lua">
+
"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. ",
mMain._main(nil, {'Wikipedia:Categorization'}, {'Help:Category'}, {'Category:Wikipedia categories'})
+
"type": "string/line",
</source>
+
"required": false,
 
+
"suggested": true
Produces:
+
},
 
+
"2": {
<code><nowiki><div role="note" class="hatnote relarticle mainarticle">Main pages: [[Wikipedia:Categorization]], [[Help:Category]] and [[:Category:Wikipedia categories]]</div></nowiki></code>
+
"label": "Page 2",
 
+
"description": "The name of the second page that you want to link to.",
Displays as:
+
"type": "string/line",
 
+
"required": false
{{main|Wikipedia:Categorization|Help:Category|Category:Wikipedia categories}}
+
},
 
+
"3": {
=== Example 3 ===
+
"label": "Page 3",
<source lang="lua">
+
"description": "The name of the third page that you want to link to. More pages can be added using the parameters \"4\", \"5\", \"6\", etc.",
mMain._main(nil, {'A', 'the letter "A"'}, {'B', 'the letter "B"'}, {'C', 'the letter "C"'})
+
"type": "string/line",
</source>
+
"required": false
 
+
},
Produces:
+
"l1": {
 
+
"type": "string/line",
<code><nowiki><div role="note" class="hatnote relarticle mainarticle">Main articles: [[A|the letter "A"]], [[B|the letter "B"]] and [[C|the letter "C"]]</div></nowiki></code>
+
"label": "Label 1",
 
+
"description": "What the first linked page is to be displayed as."
Displays as:
+
},
 
+
"l2": {
{{main|A|B|C|l1=the letter "A"|l2=the letter "B"|l3=the letter "C"}}
+
"label": "Label 2",
 
+
"description": "What the second linked page is to be displayed as.",
=== Example 4 ===
+
"type": "string/line"
<source lang="lua">
+
},
mMain._main({selfref = true}, {'Wikipedia:Verifiability#Burden'})
+
"l3": {
</source>
+
"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.",
Produces:
+
"type": "string/line"
 
+
},
<code><nowiki><div role="note" class="hatnote relarticle mainarticle selfref">Main article: [[Wikipedia:Verifiability#Burden|Wikipedia:Verifiability § Burden]]</div></nowiki></code>
+
"selfref": {
 
+
"type": "string/line",
Displays as:
+
"label": "Self reference",
 
+
"description": "Set to \"yes\" if the template is a self-reference to Wikipedia that would not make sense on mirrors or forks of the Wikipedia site."
{{main|Wikipedia:Verifiability#Burden|selfref=true}}
+
}
 
+
}
=== Example 5 (if used in the category namespace) ===
+
}
<source lang="lua">
+
</templatedata>
mMain._main(nil, {'A'})
+
{{Collapse bottom}}
</source>
 
 
 
Produces:
 
 
 
<code><nowiki><div role="note" class="hatnote relarticle mainarticle">The main article for this [[Wikipedia:Categorization|category]] is [[A]]</div></nowiki></code>
 
 
 
Displays as:
 
 
 
<div role="note" class="hatnote relarticle mainarticle">The main article for this [[Wikipedia:Categorization|category]] is [[A]]</div>
 
 
 
== Technical details ==
 
 
 
This module uses [[Module:Hatnote]] to format the hatnote text, [[Module:TableTools]] to process the list of links, and [[Module:Arguments]] to fetch the arguments from wikitext.
 
  
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
 
<!-- Categories go here and interwikis go in Wikidata. -->
 
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:Hatnote modules]]
+
[[Category:Cross-reference templates]]
 +
[[Category:Exclude in print]]
 +
[[Category:Hatnote templates]]
 +
[[Category:List templates]]
 +
[[Category:Wikipedia page-section templates]]
 +
 
 
}}</includeonly>
 
}}</includeonly>

Revision as of 04:07, 15 April 2016

When a Wikipedia 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. For example, in phthalate, the template under the "Endocrine disruptor" section should not be {{Main|Endocrine disruptor}}, because the section specifically deals with phthalate as an endocrine disruptor and not endocrine disruptors in general.

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 article}} link in the lead section would be the article itself, which is not useful. {{Broader}} may be appropriate in this case.

Usage

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

Parameters

  • 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, ...; 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. (label 1, label 2, label 3, ... for this template does not work)
  • selfref - if set to "yes", "y", "true" or "1", adds the CSS class "selfref". This is used to denote self-references to Wikipedia. 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 Wikipedia: namespace pages.

Examples

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:

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 case for {{see also}}, for example.

TemplateData
This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

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

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.

Linesuggested
Page 22

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

Lineoptional
Page 33

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

Lineoptional
Label 1l1

What the first linked page is to be displayed as.

Lineoptional
Label 2l2

What the second linked page is to be displayed as.

Lineoptional
Label 3l3

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.

Lineoptional
Self referenceselfref

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

Lineoptional