Template:Tag: Difference between revisions

From WikiMSK

(These are called attributes; no one who does HTML calls them "parameters".)
 
m (1 revision imported)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<code class="{{#ifeq:{{{wrap|}}}|yes|wrap|nowrap}}" style="{{#ifeq:{{{style|}}}|plain|border:none;background:transparent;|{{{style|}}}}}"><!--
<includeonly><span class="cm-tag {{{class|}}}"><!--
Opening tag
LINK
-->{{#switch:{{{2|pair}}}
-->[[{{{link|{{{1}}}|}}}|{{{text|{{{1}}}|}}}]]<!--
  |c|close =
 
  |e|empty|s|single|v|void
CATEGORY
  |o|open
-->[[category: {{{cat|{{{1}}}|}}}]]<!--
  |p|pair = &lt;{{#if:{{{link|}}}|[[HTML element#{{{1|tag}}}|{{{1|tag}}}]]|{{{1|tag}}}}}{{#if:{{{params|{{{attribs|}}}}}}|&#32;{{{params|{{{attribs}}}}}}}}
--><span class="cm-tag-cat-link cm-tracking-list" style="display: none;">[[:category: {{{cat|{{{1}}}|}}}|{{{list-text|&#x1F431;&#xFE0E;}}}]]</span><!--
}}<!--
 
Content between tags
--></span></includeonly><noinclude>
-->{{#switch:{{{2|pair}}}
The '''tag''' template is a link macro template that links to a page and applies a category. It's best to use it on the page's [[help: infoboxes|infobox]] rather than in the text proper.
  |c|close = {{{content|}}}
 
  |e|empty|s|single|v|void = &#32;&#47;&gt;
=== Template ===
  |o|open = &gt;{{{content|}}}
<small>'''Note:''' Replace <code><nowiki>{{1}}</nowiki></code> with an actual parameter.</small>
  |p|pair = {{#ifeq:{{{1|tag}}}|!--||&gt;}}{{{content|...}}}
<pre class=mw-code>
}}<!--
{{tag |{{1}} |cat= |text= }}
Closing tag
</pre>
-->{{#switch:{{{2|pair}}}
 
  |e|empty|s|single|v|void
=== Parameters ===
  |o|open =
Highlighted lines indicate '''mandatory''' parameters.
  |c|close
 
  |p|pair = {{#ifeq:{{{1|tag}}}|!--|--&gt;|&lt;&#47;{{{1|tag}}}&gt;}}
Positional parameters are indicated with <nowiki>{{N}}</nowiki> in their name. For example, <nowiki>{{1}}</nowiki> means "the first template parameter".
}}<!--
 
--></code><noinclude>
{{docs|title={{t|Tag}} Parameters}}
{{Documentation}}
 
</noinclude>
<!-- ------------- -->
<!-- ROW: {1} -->
<!-- ------------- -->
{{docs/row/required
|param=<nowiki>{1}</nowiki>
|desc= Use the first parameter to create a link and add the page to a category with the same name.
|eg=
<code><nowiki>|Diagram</nowiki></code>
}}
 
<!-- -------- -->
<!-- ROW: cat -->
<!-- -------- -->
{{docs/row/optional
|param=cat
|desc=Use this to add this page to a category named differently than the first parameter; if <code>cat</code> is used, the first parameter serves only as a page link.<br>
<small>'''Note:''' This is useful in cases such as when the first parameter links to a disambiguation page; for example, <code><nowiki>{{tag|Diagram}}</nowiki></code> would add the page to [[:Category:Diagram]] and link to [[Diagram]], while <code><nowiki>{{tag|Diagram (group)|cat=Diagram}}</nowiki></code> adds the page to [[:Category:Diagram]] and links to [[Diagram (group)]].</small>
|eg=
<code><nowiki>|cat=Diagram</nowiki></code>
}}
 
<!-- -------- -->
<!-- ROW: link-->
<!-- -------- -->
{{docs/row/optional
|param=link
|desc=Use this to change which page the tag links to.<br>
<small>'''Note:''' To follow from the above example, <code><nowiki>{{tag|Diagram|link=Diagram (group)}}</nowiki></code> adds the page to [[:Category:Diagram]], links to [[Diagram (group)]] and displays the tag as [[Diagram (group)|Diagram]].</small>
|eg=
<code><nowiki>|link=Diagram (group)</nowiki></code>
}}
 
 
<!-- -------- -->
<!-- ROW: text -->
<!-- -------- -->
{{docs/row/optional
|param=text
|desc=Use this to change how the tag is displayed on the page.<br>
<small>'''Note:''' To follow from the above example, <code><nowiki>{{tag|Diagram (group)|cat=Diagram|text=Patriots}}</nowiki></code> adds the page to [[:Category:Diagram]], links to [[Diagram (group)]] and displays the tag as [[Diagram (group)|Patriots]].</small>
|eg=
<code><nowiki>|text=Patriots</nowiki></code>
}}
 
|}
 
[[category: link macros]]
 
== Articles using Template ==
{{for|Special:WhatLinksHere/{{FULLPAGENAME}}|a full listing|here|pre=This list is limited to 100 pages.}}
{{Special:WhatLinksHere/{{FULLPAGENAME}}|namespace=0|limit=100}}

Latest revision as of 06:46, 11 May 2021

The tag template is a link macro template that links to a page and applies a category. It's best to use it on the page's infobox rather than in the text proper.

Template

Note: Replace {{1}} with an actual parameter.

{{tag |{{1}} |cat= |text= }}

Parameters

Highlighted lines indicate mandatory parameters.

Positional parameters are indicated with {{N}} in their name. For example, {{1}} means "the first template parameter".

{{Tag}} Parameters
Parameter Description Examples
{1} Use the first parameter to create a link and add the page to a category with the same name.

|Diagram

cat Use this to add this page to a category named differently than the first parameter; if cat is used, the first parameter serves only as a page link.

Note: This is useful in cases such as when the first parameter links to a disambiguation page; for example, {{tag|Diagram}} would add the page to Category:Diagram and link to Diagram, while {{tag|Diagram (group)|cat=Diagram}} adds the page to Category:Diagram and links to Diagram (group).

|cat=Diagram

link Use this to change which page the tag links to.

Note: To follow from the above example, {{tag|Diagram|link=Diagram (group)}} adds the page to Category:Diagram, links to Diagram (group) and displays the tag as Diagram.

|link=Diagram (group)

text Use this to change how the tag is displayed on the page.

Note: To follow from the above example, {{tag|Diagram (group)|cat=Diagram|text=Patriots}} adds the page to Category:Diagram, links to Diagram (group) and displays the tag as Patriots.

|text=Patriots

Articles using Template