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:Sandbox/Was a bee/getLinkedName
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!
local p = {} function p.rmvDisambigBracket ( text ) text = string.gsub( text, '%s%(.+%)$', '' ) return text end function p.getLinkedName( frame ) local id = frame.args[1] local alias = frame.args['alias'] if id == nil or id == '' then --If QID is not defined, using the QID of the item which is connected to the current page. id = mw.wikibase.getEntityIdForCurrentPage() if not id then return 'No item passed as parameter' --If there is no connected wikidata page, abort. end end if tonumber(id) then --legacy format id = 'Q'.. tostring(id) end local lang = mw.language.getContentLanguage().code local globalSiteId = lang .. 'wiki' local entity = mw.wikibase.getEntity( id ) local content local currentText = nil local currentText_NoBracket = nil currentText = entity:getSitelink( globalSiteId ) if currentText ~= nil then if alias ~= nil and alias ~= '' then currentText_NoBracket = alias else currentText_NoBracket = p.rmvDisambigBracket(currentText) end content = '[[:' .. lang .. ':' .. currentText .. '|' .. currentText_NoBracket .. ']]' return content ---- 1. [[:en:Sitelink|Sitelink]] style else currentText = entity:getLabelWithLang(lang) if currentText ~= nil then content = '[[:' .. lang .. ':' .. currentText .. '|' .. currentText .. ']]' return content ---- 2. [[:en:Label|Label]] style else content = id .. ' ' .. '[[File:Blue pencil.svg|frameless|text-top|10px|link=https://www.wikidata.org/wiki/' .. id .. ']]' return content ---- 3. Q123456 style end end 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)
Stockhub entities used in this page
Hirose Shrine
: Sitelink, Label: en-gb
United States of America
: Sitelink, Label: en-gb
Douglas Adams
: Sitelink, Label: en-gb
John Smith
: Sitelink, Label: en-gb
Templates used on this page:
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Para
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Sandbox/Was a bee/getLinkedName
(
edit
)
Module:Sandbox/Was a bee/getLinkedName/doc
(
edit
)
Module:Yesno
(
edit
)