Difference between revisions of "Template:Anchor"

From Starfleet Commander
Jump to navigationJump to search
(Created page with "<span id="{{{1|<span class="error">Required parameter missing.</span>}}}"></span><noinclude> ==Template documentation== The template {{anchor}} inserts one [http://en.wikipedia.o...")
 
m
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<span id="{{{1|<span class="error">Required parameter missing.</span>}}}"></span><noinclude>
+
<span id="{{{1|<span class="error">Missing reqired parameter</span>}}}">{{{2|}}}</span><noinclude>
==Template documentation==
+
{{Doc-begin}}
The template {{anchor}} inserts one [http://en.wikipedia.org/wiki/HTML_element#Anchor HTML anchors] in a page. The location can then be linked to using [[#link|...]] syntax.
+
__TOC__
 +
{{Note}}When viewing this template it shows: &lt;span id="<span style="color:red">Missing reqired parameter</span>">&lt;/span> it's not an error.
 +
==Functonality==
 +
Creates an [[Wikipedia:HTML element#Anchor|HTML anchor]].
  
===Examples===
+
This template is used to create a single tag or anchor.
1. <code style="color:green;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}|foo<nowiki>}}</nowiki></code>
+
<nowiki>{{Anchor|id|Text to display}}</nowiki>
: could be linked to with <tt><nowiki>[[#foo|...]]</nowiki></tt> from within the same article,
 
: or it could be linked to with <tt><nowiki>[[</nowiki>''<small>articlename</small>''#foo|...<nowiki>]]</nowiki></tt> from other articles and from redirects.
 
  
2. Anchors can be more suitable for inter-article linking than section titles are. For example,
+
==Usage==
:<code style="color:gray;"><nowiki>==</nowiki> <code style="color:green;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}|foo<nowiki>}}</nowiki></code> Section title <nowiki>==</nowiki></code>
+
<nowiki>{{Anchor|parameter1|parameter2}}</nowiki>
:Here, links via <tt><nowiki>[[</nowiki>''articlename''#foo<nowiki>]]</nowiki></tt> would remain valid even if the section were renamed.
 
  
3. The template can be used to create up to ten anchors with a single call. For example,
+
* '''parameter1''' &mdash; ''required''
: <code style="color:green;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}|foo|bar|baz<nowiki>}}</nowiki></code>
+
*: This indicates the name of the HTML anchor
:will create three anchors that can then be linked to with <tt><nowiki>[[#foo]]</nowiki></tt>, <tt><nowiki>[[#bar]]</nowiki></tt> and <tt><nowiki>[[#baz]]</nowiki></tt>.
+
 
:Specifying more than 10 anchors will cause an error message to be displayed.{{#ifeq:{{BASEPAGENAME}}|Visible anchor|<br />
+
* '''parameter2''' &mdash; ''optional''
<br />
+
*: This creates text to display at the location of the template
4. If the text to be displayed must differ from the anchor (e.g. because it contains brackets for linking), the <code style="color:green;">text</code> parameter can be used:
+
 
: <code style="color:green;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}<nowiki>|foo|text=[[foo]]}}</nowiki></code>
+
In order to access this link anchor, use <nowiki>[[</nowiki>[[{{FULLPAGENAME}}#{{{1|parameter1}}}|examplepagename#parameter1]]<nowiki>]]</nowiki>
: this will result in a link that constitutes an anchor of its own|}}
+
 
 +
==Example==
 +
<nowiki>{{Anchor|parameter1|parameter2}}</nowiki>
 +
 
 +
{{Anchor|parameter1|parameter2}}
 +
 
 +
[[Category:Templates|{{PAGENAME}}]]
 +
{{Doc-end}}
 
</noinclude>
 
</noinclude>

Latest revision as of 04:13, 20 September 2011

<span id="Missing reqired parameter">

Template Documentation Icon.png Template documentation

Light Bulb Icon.png Note: When viewing this template it shows: <span id="Missing reqired parameter"></span> it's not an error.

Functonality

Creates an HTML anchor.

This template is used to create a single tag or anchor.

{{Anchor|id|Text to display}}

Usage

{{Anchor|parameter1|parameter2}}

  • parameter1required
    This indicates the name of the HTML anchor
  • parameter2optional
    This creates text to display at the location of the template

In order to access this link anchor, use [[examplepagename#parameter1]]

Example

{{Anchor|parameter1|parameter2}}

parameter2