Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage from wikitext  



1.1  otheruses()  





1.2  otherX()  







2 Usage from Lua  



2.1  Parameters of _otheruses()  
















Module:Other uses






العربية
Azərbaycanca
تۆرکجه
Basa Bali


Bosanski
Буряад
Català
فارسی
Fiji Hindi
Gaeilge
Gàidhlig

ि
Ilokano
Bahasa Indonesia
Íslenska
Jawa

Madhurâ


Bahasa Melayu

ି

Русиньскый

Scots

Simple English
Slovenščina
کوردی
Српски / srpski
Srpskohrvatski / српскохрватски
Sunda
ி
Taqbaylit
 

Tiếng Vit

 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


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.defaultPageoroptions.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"

local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools --initialize lazily
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}

-- Produces standard {{other uses}} implementation
function p.otheruses(frame)
 mArguments = require('Module:Arguments')
 mTableTools = require('Module:TableTools')
 local args = mTableTools.compressSparseArray(mArguments.getArgs(frame))
 local title = mw.title.getCurrentTitle().prefixedText
 return p._otheruses(args, {title=title})
end

--Implements "other [x]" templates with otherText supplied at invocation
function p.otherX(frame)
 mArguments = require('Module:Arguments')
 mTableTools = require('Module:TableTools')
 local x = frame.args[1]
 local args = mTableTools.compressSparseArray(
  mArguments.getArgs(frame, {parentOnly = true})
 )
 local options = {
  title = mw.title.getCurrentTitle().prefixedText,
  otherText = x
 }
 return p._otheruses(args, options)
end

-- Main generator
function p._otheruses(args, options)
 --Type-checks and defaults
 checkType('_otheruses', 1, args, 'table', true)
 args = args or {}
 checkType('_otheruses', 2, options, 'table')
 if not (options.defaultPage or options.title) then
  error('No default title data provided in "_otheruses" options table', 2)
 end
 local emptyArgs = true
 for k, v in pairs(args) do
  if type(k) == 'number' then emptyArgs = false break end
 end
 if emptyArgs then
  args = {
   options.defaultPage or
   mHatnote.disambiguate(options.title, options.disambiguator)
  }
 end
 --Generate and return hatnote
 local text = mHatlist.forSeeTableToString({{
  use = options.otherText and "other " .. options.otherText or nil,
  pages = args
 }})
 return mHatnote._hatnote(text)
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Other_uses&oldid=960249960"

Categories: 
Modules subject to page protection
Hatnote modules
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 1 June 2020, at 23:06 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki