Difference between revisions of "Template:Anchor"

From Starfleet Commander
Jump to navigationJump to search
m
m
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==
+
==Functonality==
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.
+
Creates an [[Wikipedia:HTML element#Anchor|HTML anchor]].
  
===Examples===
+
This template is used for a single tag.
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>
+
{{tlx|section|parameter1|parameter2}}
:Here, links via <tt><nowiki>[[</nowiki>''articlename''#foo<nowiki>]]</nowiki></tt> would remain valid even if the section were renamed.
+
 
 +
* '''parameter1''' &mdash; ''required''
 +
*: This indicates the name of the HTML anchor
 +
 
 +
* '''parameter2''' &mdash; ''optional''
 +
*: This creates text to display at the location of the template
 +
 
 +
In order to access this link anchor, use [[{{PAGENAME}}#{{parameter1|examplepagename#parameter1}}]]
 +
 
 +
==Example==
 +
<nowiki>{{Anchor|parameter1|parameter2}}</nowiki>
 +
 
 +
{{Anchor|parameter1|parameter2}}
 +
 
 +
 
 +
}}
 +
 
 +
[[Category:Templates|{{PAGENAME}}]]
  
3. The template can be used to create up to ten anchors with a single call. For example,
 
: <code style="color:green;"><nowiki>{{</nowiki>{{lc:{{BASEPAGENAME}}}}|foo|bar|baz<nowiki>}}</nowiki></code>
 
: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 />
 
<br />
 
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>
 
: this will result in a link that constitutes an anchor of its own|}}
 
 
</noinclude>
 
</noinclude>

Revision as of 22:54, 19 September 2011

<span id="Missing reqired parameter">

Functonality

Creates an HTML anchor.

This template is used for a single tag.

{{Anchor|id|Text to display}}

Usage

Template:Tlx

  • 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 [[Anchor#Template:Parameter1]]

Example

{{Anchor|parameter1|parameter2}}

parameter2


}}