Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Category pair
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require('strict') local getArgs = require('Module:Arguments').getArgs local hatnote = require('Module:Hatnote')._hatnote local formatLink = require('Module:Format link')._formatLink local p = {} local catNS = mw.site.namespaces.Category.id -- category namespace number -- Lua implementation of [[Template:CategoryPair]] -- Arguments: -- prevTitle -- mw.title.Title object for preceding category -- nextTitle -- mw.title.Title object for succeeding category -- Returns: -- hatnote that says "see also" for one or both of prev/next (depending on whether they exist) function p._pair(prevTitle, nextTitle) prevTitle = prevTitle and prevTitle.exists and formatLink{link = prevTitle.fullText} nextTitle = nextTitle and nextTitle.exists and formatLink{link = nextTitle.fullText} local note = '' if prevTitle and nextTitle then -- if both note = mw.ustring.format('See also the preceding %s and the succeeding %s',prevTitle, nextTitle) elseif prevTitle then -- if only prevTitle note = mw.ustring.format('See also the preceding %s', prevTitle) elseif nextTitle then -- if only nextTitle note = mw.ustring.format('See also the succeeding %s', nextTitle) else -- otherwise neither return mw.title.getCurrentTitle().namespace == catNS and '[[Category:Pages using category pair with no output]]' or '' end return hatnote(note, {extraclasses = 'seealso'}) end function p.catPair(frame) local args = getArgs(frame, {wrappers={'Template:Category pair'}}) local prevTitle = args[1] and mw.title.new(args[1],catNS) local nextTitle = args[2] and mw.title.new(args[2],catNS) return p._pair(prevTitle, nextTitle) end function p.prevCat(frame) local args = getArgs(frame, {wrappers={'Template:Preceding category'}}) local prevTitle = args[1] and mw.title.new(args[1], catNS) return p._pair(prevTitle, nil) end function p.nextCat(frame) local args = getArgs(frame, {wrappers={'Template:Succeeding category'}}) local nextTitle = args[1] and mw.title.new(args[1], catNS) return p._pair(nil, nextTitle) end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:High use
(
edit
)
Template:Lua
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Sandbox other
(
edit
)
Template:Tl
(
edit
)
Module:Arguments
(
edit
)
Module:Category pair/doc
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:String
(
edit
)
Module:Yesno
(
edit
)