请输入您要查询的百科知识:

 

词条 Module:ResolveEntityId/doc
释义

  1. Usage

      Call from within a module (_id)    Use from within a template (entityid)    Deprecated (_entityid)  
{{Module rating |beta}}{{High-risk|~1200000}}

Usage

Functions similarly to mw.wikibase.resolvePropertyId, but for Wikidata entities instead of properties.

Returns an entity id for the given label or id. This allows using the entity's labels instead of ids in all places. If no entity was found for the label or id, or if the label is ambiguous, a nil value is returned.

When attempting to resolve a label, only entities with English Wikipedia sitelinks are considered in the search. If a label exists in Wikidata, but does not have the requisite language sitelink, a nil value is returned.

Call from within a module (_id)

Example calls within a module might look like the following:

Code Result
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('Q42')

id = {{#invoke:ResolveEntityId|entityid|Q42|nil}}
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('Q0')

id = {{#invoke:ResolveEntityId|entityid|Q0|nil}}
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('Q404')

id = {{#invoke:ResolveEntityId|entityid|Q404|nil}}
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('Q151384451555')

id = {{#invoke:ResolveEntityId|entityid|Q151384451555|nil}}
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('Douglas Adams')

id = {{#invoke:ResolveEntityId|entityid|Douglas Adams|nil}}
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('ThisIsNotARealWikidataItem')

id = {{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|nil}}
local resolveEntity = require( "Module:ResolveEntityId" )

id = resolveEntity._id('ThisIsNotARealWikidataItem', 'Wikidata ID not found!')

id = {{#invoke:ResolveEntityId|entityid|ThisIsNotARealWikidataItem|'Wikidata ID not found!'}}

Use from within a template (entityid)

The following will return the entity id (or nil if the ID doesn't exist):

{{#invoke:{{BASEPAGENAME}}|entityid|id}}

The following will return the entity id (or the alternate text if the ID doesn't exist):

{{#invoke:{{BASEPAGENAME}}|entityid|id|alternate text if id is nil}}

Deprecated (_entityid)

The _entityid function, which required that the frame be passed as the first argument, has been deprecated because workarounds are no longer needed for phab:T143970.

{{#ifeq:{{SUBPAGENAME}}|sandbox | |

}}

1 : Wikidata modules

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/30 12:35:37