Module:Other uses
- العربية
- Azərbaycanca
- تۆرکجه
- Basa Bali
- বাংলা
- भोजपुरी
- Bikol Central
- Bosanski
- Буряад
- Català
- فارسی
- Fiji Hindi
- Gaeilge
- Gàidhlig
- 한국어
- हिन्दी
- Ilokano
- Bahasa Indonesia
- Íslenska
- Jawa
- ಕನ್ನಡ
- Madhurâ
- മലയാളം
- मराठी
- Bahasa Melayu
- Монгол
- မြန်မာဘာသာ
- ଓଡ଼ିଆ
- ਪੰਜਾਬੀ
- پښتو
- Русиньскый
- ᱥᱟᱱᱛᱟᱲᱤ
- Scots
- සිංහල
- Simple English
- Slovenščina
- کوردی
- Srpskohrvatski / српскохрватски
- Sunda
- Tagalog
- தமிழ்
- Taqbaylit
- တႆး
- ไทย
- Türkmençe
- Українська
- Tiếng Việt
- 中文
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
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:
localmOtheruses=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 themw.text.listToText()function the module uses. If in doubt, usecompressSparseArray()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.defaultPageoroptions.title; in most cases setting the latter tomw.title.getCurrentTitle().prefixedTextis advisable. The following options are supported:defaultPage: String; completely overrides the linked page when no arguments are suppliedtitle: String; sets the title used before the "(disambiguation)" suffix.disambiguator: String; replaces "disambiguation" in the suffixotherText: String; replaces "uses" in "other uses"
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
localmHatnote=require('Module:Hatnote') localmHatlist=require('Module:Hatnote list') localmArguments--initialize lazily localmTableTools--initialize lazily locallibraryUtil=require('libraryUtil') localcheckType=libraryUtil.checkType localp={} -- Produces standard {{other uses}} implementation functionp.otheruses(frame) mArguments=require('Module:Arguments') mTableTools=require('Module:TableTools') localargs=mTableTools.compressSparseArray(mArguments.getArgs(frame)) localtitle=mw.title.getCurrentTitle().prefixedText returnp._otheruses(args,{title=title}) end --Implements "other [x]" templates with otherText supplied at invocation functionp.otherX(frame) mArguments=require('Module:Arguments') mTableTools=require('Module:TableTools') localx=frame.args[1] localargs=mTableTools.compressSparseArray( mArguments.getArgs(frame,{parentOnly=true}) ) localoptions={ title=mw.title.getCurrentTitle().prefixedText, otherText=x } returnp._otheruses(args,options) end -- Main generator functionp._otheruses(args,options) --Type-checks and defaults checkType('_otheruses',1,args,'table',true) args=argsor{} checkType('_otheruses',2,options,'table') ifnot(options.defaultPageoroptions.title)then error('No default title data provided in "_otheruses" options table',2) end localemptyArgs=true fork,vinpairs(args)do iftype(k)=='number'thenemptyArgs=falsebreakend end ifemptyArgsthen args={ options.defaultPageor mHatnote.disambiguate(options.title,options.disambiguator) } end --Generate and return hatnote localtext=mHatlist.forSeeTableToString({{ use=options.otherTextand"other "..options.otherTextornil, pages=args }}) returnmHatnote._hatnote(text) end returnp