Template:Anchor: Difference between revisions

From OniGalore
Jump to navigation Jump to search
(this?)
m (link fix in docs)
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--
<noinclude>When a header is created in an article with the notation "==Header Name==", it creates an HTML span id, which is also known as an anchor link; a URL or intrawiki link can then use the "#" mark to link to that specific section by name. Sometimes you want an article to provide such an anchor link but you don't want to give that part of the article its own header, or perhaps it already has a header and you want to give it an alternate name as a sort of alias.
-->{{#if:{{{ 1|}}}|<span id="{{anchorencode:{{{ 1|}}}}}" </span id><!--
 
-->{{#if:{{{ 2|}}}|<span id="{{anchorencode:{{{ 2|}}}}}" /><!--
There's where this template comes in. Here are some examples of how it's been used on OniGalore:
-->{{#if:{{{ 3|}}}|<span id="{{anchorencode:{{{ 3|}}}}}" /><!--
*<nowiki>{{Anchor|Manifesto}}</nowiki> was used on the "Quotes/Manual" page to allow linking to the Pre-Mission Briefing section under its alternate name, "Manifesto": [[Quotes/Manual#Manifesto]].
-->{{#if:{{{ 4|}}}|<span id="{{anchorencode:{{{ 4|}}}}}" /><!--
*<nowiki>{{Anchor|2001}}</nowiki>, etc. was used on the "History of the Oni community" page so that links from other pages could simply point to a year and the reader could be forwarded to that chronological point in the article regardless of how the text is broken into sections, e.g. [[History of the Oni community#2001]].
-->{{#if:{{{ 5|}}}|<span id="{{anchorencode:{{{ 5|}}}}}" /><!--
*<nowiki>{{Anchor|textures_tag}}</nowiki> was used on "Creating a level" to allow a specific field within a table to be linked to: [[Creating a level#textures_tag]].
-->{{#if:{{{ 6|}}}|<span id="{{anchorencode:{{{ 6|}}}}}" /><!--
 
-->{{#if:{{{ 7|}}}|<span id="{{anchorencode:{{{ 7|}}}}}" /><!--
Handy, huh? Note that you can create up to ten anchors by supplying multiple parameters, e.g. <nowiki>{{Anchor|one|two|three}}</nowiki>, though this capability is probably not being used anywhere on the wiki.
-->{{#if:{{{ 8|}}}|<span id="{{anchorencode:{{{ 8|}}}}}" /><!--
 
-->{{#if:{{{ 9|}}}|<span id="{{anchorencode:{{{ 9|}}}}}" /><!--
P.S.: The original goal in introducing this template was to create a custom TOC based on this invisible section markup that could be used to document [[BSL:Tutorial/airport1_level_logic.bsl|raw BSL]]; however, no simple solution to the issue of how to create a TOC from span ids has been found yet.
-->{{#if:{{{10|}}}|<span id="{{anchorencode:{{{10|}}}}}" /><!--
[[Category:Basic formatting templates]]</noinclude><includeonly>{{#if:{{{1|}}}|<span id="{{{1|}}}"></span>}}<!--
-->{{#if:{{{11|}}}
-->{{#if:{{{2|}}}|<span id="{{{2|}}}"></span>}}<!--
    |<div style="background:yellow">[[Template:Anchor]]: too many anchors</div><!--
-->{{#if:{{{3|}}}|<span id="{{{3|}}}"></span>}}<!--
-->}}<!--
-->{{#if:{{{4|}}}|<span id="{{{4|}}}"></span>}}<!--
-->}} }} }} }} }} }} }} }} }} }}
-->{{#if:{{{5|}}}|<span id="{{{5|}}}"></span>}}<!--
-->{{#if:{{{6|}}}|<span id="{{{6|}}}"></span>}}<!--
-->{{#if:{{{7|}}}|<span id="{{{7|}}}"></span>}}<!--
-->{{#if:{{{8|}}}|<span id="{{{8|}}}"></span>}}<!--
-->{{#if:{{{9|}}}|<span id="{{{9|}}}"></span>}}<!--
-->{{#if:{{{10|}}}|<span id="{{{10|}}}"></span>}}<!--
-->{{#if:{{{11|}}}|<span class="error">[[Template:Anchor]]: too many anchors, maximum is 10.</span>}}</includeonly>

Latest revision as of 01:25, 20 November 2023

When a header is created in an article with the notation "==Header Name==", it creates an HTML span id, which is also known as an anchor link; a URL or intrawiki link can then use the "#" mark to link to that specific section by name. Sometimes you want an article to provide such an anchor link but you don't want to give that part of the article its own header, or perhaps it already has a header and you want to give it an alternate name as a sort of alias.

There's where this template comes in. Here are some examples of how it's been used on OniGalore:

  • {{Anchor|Manifesto}} was used on the "Quotes/Manual" page to allow linking to the Pre-Mission Briefing section under its alternate name, "Manifesto": Quotes/Manual#Manifesto.
  • {{Anchor|2001}}, etc. was used on the "History of the Oni community" page so that links from other pages could simply point to a year and the reader could be forwarded to that chronological point in the article regardless of how the text is broken into sections, e.g. History of the Oni community#2001.
  • {{Anchor|textures_tag}} was used on "Creating a level" to allow a specific field within a table to be linked to: Creating a level#textures_tag.

Handy, huh? Note that you can create up to ten anchors by supplying multiple parameters, e.g. {{Anchor|one|two|three}}, though this capability is probably not being used anywhere on the wiki.

P.S.: The original goal in introducing this template was to create a custom TOC based on this invisible section markup that could be used to document raw BSL; however, no simple solution to the issue of how to create a TOC from span ids has been found yet.