Jump to content

Module:Other uses/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m for real
m change source to syntaxhighlight
Line 11: Line 11:
The <code>otherX()</code> function allows direct implementation of templates that differ from {{tl|other uses}} in only phrasing. For example, where {{tl|other uses}} is phrased with "other uses", {{tl|other places}} is phrased with "other places with the same name" and can be implemented using <code>otherX()</code>, which takes the custom phrasing as its parameter at the module invocation. {{tl|other places}} in particular could be implemented with this wikitext:
The <code>otherX()</code> function allows direct implementation of templates that differ from {{tl|other uses}} in only phrasing. For example, where {{tl|other uses}} is phrased with "other uses", {{tl|other places}} is phrased with "other places with the same name" and can be implemented using <code>otherX()</code>, which takes the custom phrasing as its parameter at the module invocation. {{tl|other places}} in particular could be implemented with this wikitext:


<source lang="text">{{#invoke:other uses|otherX|places with the same name}}</source>
<syntaxhighlight lang="text">{{#invoke:other uses|otherX|places with the same name}}</syntaxhighlight>


Note that the leading "other" is automatically supplied; if a template would not use this phrasing, it should not use <code>otherX()</code>.
Note that the leading "other" is automatically supplied; if a template would not use this phrasing, it should not use <code>otherX()</code>.
Line 18: Line 18:
To use this module from Lua, first load the module:
To use this module from Lua, first load the module:


<source lang="lua">
<syntaxhighlight lang="lua">
local mOtheruses = require('Module:Other uses')
local mOtheruses = require('Module:Other uses')
</syntaxhighlight>
</source>


The module functions can then be used through the <code>_otheruses()</code> function:
The module functions can then be used through the <code>_otheruses()</code> function:


<source lang="lua">
<syntaxhighlight lang="lua">
mOtheruses._otheruses(args, options)
mOtheruses._otheruses(args, options)
</syntaxhighlight>
</source>


===Parameters of <code>_otheruses()</code>===
===Parameters of <code>_otheruses()</code>===

Revision as of 13:23, 7 July 2020

This module produces an "other uses" hatnote for linking to disambiguation pages. It implements the {{other uses}} template.

Usage from wikitext

otheruses()

The otheruses() function directly implements {{other uses}} and probably shouldn't be used anywhere else.

otherX()

The otherX() function allows direct implementation of templates that differ from {{other uses}} in only phrasing. For example, where {{other uses}} is phrased with "other uses", {{other places}} is phrased with "other places with the same name" and can be implemented using otherX(), which takes the custom phrasing as its parameter at the module invocation. {{other places}} in particular could be implemented with this wikitext:

{{#invoke:other uses|otherX|places with the same name}}

Note that the leading "other" is automatically supplied; if a template would not use this phrasing, it should not use otherX().

Usage from Lua

To use this module from Lua, first load the module:

local mOtheruses = require('Module:Other uses')

The module functions can then be used through the _otheruses() function:

mOtheruses._otheruses(args, options)

Parameters of _otheruses()

args
A table containing strings of link text, without brackets. For example, {"PAGE1", "PAGE2#SECTION", "PAGE3|LABEL"}. Make sure that there are no gaps or nil values, as that can confuse the mw.text.listToText() function the module uses. If in doubt, use compressSparseArray() from Module:TableTools. This may be empty or nil.
options
A table containing a number of optional named values; you must supply at least one of options.defaultPage or options.title; in most cases setting the latter to mw.title.getCurrentTitle().prefixedText is advisable. The following options are supported:
  • defaultPage: String; completely overrides the linked page when no arguments are supplied
  • title: String; sets the title used before the "(disambiguation)" suffix.
  • disambiguator: String; replaces "disambiguation" in the suffix
  • otherText: String; replaces "uses" in "other uses"