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:WikidataIdentifiers
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!
-- Functions for use in retrieving Wikidata for use in templates that deal with identifiers -- getIdentifierQualifier returns the value of a qualifier for an Identifier p = {} -- getIdentifierQualifier returns the value of a qualifier for an Identifier -- such as 'Art UK artist ID', P1367 -- the assumption is that one value exists for the property -- and only one qualifier exists for that value -- Constraint violations for P1367 are at: -- https://www.wikidata.org/wiki/Wikidata:Database_reports/Constraint_violations/P1367#Single_value p.getIdentifierQualifier = function(frame) local propertyID = mw.text.trim(frame.args[1] or "") -- The PropertyID of the qualifier -- whose value is to be returned is passed in named parameter |qual= local qualifierID = frame.args.qual -- Can take a named parameter |qid which is the Wikidata ID for the article. -- This will not normally be used because it's an expensive call. local qid = frame.args.qid if qid and (#qid == 0) then qid = nil end local entity = mw.wikibase.getEntityObject(qid) local props if entity and entity.claims then props = entity.claims[propertyID] end if props then -- Check that the first value of the property is an external id if props[1].mainsnak.datatype == "external-id" then -- get any qualifiers of the first value of the property local quals = props[1].qualifiers if quals and quals[qualifierID] then -- check what the dataype of the first qualifier value is -- if it's quantity return the amount if quals[qualifierID][1].datatype == "quantity" then return tonumber(quals[qualifierID][1].datavalue.value.amount) end -- checks for other datatypes go here: end 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
quantity
: Miscellaneous (e.g. aliases, entity existence), Label: en-gb
Art UK artist identifier
: Miscellaneous (e.g. aliases, entity existence), Label: en-gb
Charles Walter Simpson
: Miscellaneous (e.g. aliases, entity existence), Label: en-gb, Statement: P1367
Templates used on this page:
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Q
(
edit
)
Module:Arguments
(
edit
)
Module:Effective protection level
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Wd
(
edit
)
Module:Wd/i18n
(
edit
)
Module:WikidataIdentifiers
(
edit
)
Module:WikidataIdentifiers/doc
(
edit
)
Module:Yesno
(
edit
)