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:ResolveEntityId/doc
(section)
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!
=== Call from within a module (_id) === Example calls within a module might look like the following: {| class="wikitable" |+ style="text-align:left"| !Code !! Result !! Notes |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Q42')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q42|'''nil'''}}</code> | "Q42" is a valid Wikidata ID, and a Wikidata items exists with that Id, so it is therefore returned intact |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Q0')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q0|'''nil'''}}</code> | "Q0" is not a valid Wikidata ID, and while the Wikipedia article [[Q0]] exists, it is a disambiguation page, so <code>'''nil'''</code> is returned |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Q404')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q404|'''nil'''}}</code> | "Q404" is a Wikidata redirect to Q395, so the latter is returned |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Q2147483647')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Q2147483647|'''nil'''}}</code> | Q2147483647 is a valid Wikidata ID, but no entity exists with that ID, so <code>'''nil'''</code> is returned |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Douglas Adams')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Douglas Adams|'''nil'''}}</code> | The article [[Douglas Adams]] exists and has the Wikidata ID "Q42", so that is returned. |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('ThisIsNotARealWikidataItem')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|'''nil'''}}</code> | "ThisIsNotARealWikidataItem" is not a valid Wikidata ID, and no Wikipedia article exists at [[ThisIsNotARealWikidataItem]], so <code>'''nil'''</code> is returned |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('ThisIsNotARealWikidataItem', 'Wikidata ID not found!')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|'Wikidata ID not found!'}}</code> | Same as above, but the custom error message <code>Wikidata ID not found!</code> is returned |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Douglas adams')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Douglas adams|'''nil'''}}</code> | "Douglas adams" is not a valid Wikidata ID, and while [[Douglas adams]] (with a lower-case "a") exists, it is a redirect to [[Douglas Adams]]. Therefore the Wikidata ID for the latter page is returned |- |<syntaxhighlight lang="lua">local resolveEntityId = require( "Module:ResolveEntityId" )._id id = resolveEntityId('Wikipedia:Village pump (technical)/Archive 1')</syntaxhighlight> |style="vertical-align: mid;"|<code>id</code> = <code>{{#invoke:ResolveEntityId|entityid|Wikipedia:Village pump (technical)/Archive 1|'''nil'''}}</code> | "Wikipedia:Village pump (technical)/Archive 1" is not a valid Wikidata ID, and while [[Wikipedia:Village pump (technical)/Archive 1]] exists, it does not have a Wikidata ID, so <code>'''nil'''</code> is returned |}
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)