FANDOM


LinkTemplate is a library that can be used to easily create link templates.

Installation

Create a page called Module:LinkTemplate on your wiki with the following content:

return require('Dev:LinkTemplate')

Usage

Use this template to create Link Templates, to either other wikis, namespaces, and pages.

  • External
    • Add {{#invoke:LinkTemplate|main|external|<website to link to (optional)>|<default text (optional)>}} to your template.
    • Then use the template.
      • {{<templatename>}} returns a plainlink to the default website if it has been specified.
      • {{<templatename>|<arg>}} returns a plainlink to the default website with different text or a link to a specified website.
      • {{<templatename>|<link>|<text>}} links to the first arg with the text being the second arg.
  • Interwiki
    • Add {{#invoke:LinkTemplate|main|wiki|<wiki url name>|<full wiki name>}} to your template.
    • Then use the template.
      • {{<templatename>}} returns a link to the wiki with the default text being its full wiki name.
      • {{<templatename>|<page>}} returns a link to the page with the text being the page's name.
      • {{<templatename>|<page>|<text>}} links to the same page as the above but with different text.
      • {{<templatename>|url=useskin-oasis&uselang-en}} adds URL parameters.
  • MediaWiki
    • Add {{#invoke:LinkTemplate|main|mediawiki|<link prefix>|<full site name>}} to your template.
    • Then use the template.
      • {{<templatename>}} returns a link to the site with the default text being its full name.
      • {{<templatename>|<page>}} returns a link to the page with the text being the page's name.
      • {{<templatename>|<page>|<text>}} links to the same page as the above but with different text.
      • {{<templatename>|url=useskin-oasis&uselang-en}} adds URL parameters.
  • Namespace
    • Add {{#invoke:LinkTemplate|main|ns|<namespace number>}} to your template.
    • Then use the template.
      • {{<templatename>}} returns a link to the all pages in that namespace with the default text being the namespace's name.
      • {{<templatename>|<page>}} returns a link to a page in the namespace; the text is the page's name.
      • {{<templatename>|<page>|<text>}} links to the same page as the above but with different text.
      • {{<templatename>|<page>|f}} links to the page but with both the namespace and the name displayed.
      • {{<templatename>|url=useskin-oasis&uselang-en}} adds URL parameters.
  • Page
    • Add {{#invoke:LinkTemplate|main|page|<page name>|<default text (optional)>}} to your template.
    • Then use the template.
      • {{<templatename>}} returns a link to the the page with the text being the page's name.
      • {{<templatename>|<name>}} returns a link to the page; the text is the first arg.
      • {{<templatename>|url=useskin-oasis&uselang-en}} adds URL parameters.

Changelog

v1.0 — November 15, 2018
TheGoldenPatrik1: Initial revision
v1.1 — November 28, 2018
TheGoldenPatrik1: Add error handling
v1.2 — December 6, 2018
TheGoldenPatrik1: Add page link
v1.3 — December 10, 2018
TheGoldenPatrik1: Add external plain link
v1.4 — December 12, 2018
TheGoldenPatrik1: Add inter-mediawiki link
Community content is available under CC-BY-SA unless otherwise noted.