Bản mẫu:Get QID
Q26090228
| Bản mẫu này được sử dụng ở khoảng 31.000 trang, vì thế những thay đổi đến nó sẽ hiện ra rõ ràng. Vui lòng thử nghiệm các thay đổi ở trang con /sandbox, /testcases của bản mẫu, hoặc ở không gian người dùng của bạn. Cân nhắc thảo luận các thay đổi tại trang thảo luận trước khi áp dụng sửa đổi. |
| Bản mẫu này sử dụng Lua: |
Usage
[sửa mã nguồn]This template retrieves the Wikidata unique identifier (QID) that corresponds to the Wikipedia page (or redirection page) title (known in Wikidata terminology as a Wikidata item's Wikipedia sitelink, not to be confused with its label) specified in the first unnamed parameter. If a page is moved, a {{Get QID|<page title>}} call referring to its former title typically still works, since the template follows the redirection destination, if the redirection source does not have a Wikidata item of its own. If no parameter is given ({{Get QID}}), it retrieves the QID of the current page. If the qid parameter is defined ({{get QID}}) the template just passes the given value on.
Current page
[sửa mã nguồn]Example:
{{Get QID}} → Q26090228
gives the QID of the current Wikipedia page, or an empty text string if no QID is defined.
Articles sharing the same label
[sửa mã nguồn]The template does not do lookups of a Wikidata label, but of a Wikipedia page title. For example, the following two pages have the same Wikidata label, Mars:
{{Get QID|Mars}}→ Q426315{{Get QID|Mars (mythology)}}→
The template will return the QIDs of Mars (planet) and Mars (mythology) respectively.
Redirection page
[sửa mã nguồn]The page universes is a redirect to universe, and does not have its own defined Wikidata item:
{{Get QID|universes}} →
gives the QID of the page universe.
Usage together with the Q template:
{{Q|{{Get QID|universes}}}} → Bản mẫu:Get QID (Q26090228)
Redirection page with its own Wikidata item
[sửa mã nguồn]Maryport New Lighthouse is redirected to Maryport Lighthouse, each having separate Wikidata items:
{{Q|{{Get QID|Maryport New Lighthouse}}}} → Bản mẫu:Get QID (Q26090228)
Passing QID parameter on
[sửa mã nguồn]{{Get QID|qid=Q111}} → Q111
Substitution
[sửa mã nguồn]To make Wikipedia faster, and to make the result less vulnerable to future deletion of redirects, this template may be substituted: {{subst:Get QID|<page title>}}, for example:
{{subst:Get QID|universe}} → Q1
which is immediately replaced by the resulting QID when saved.
However, a purpose of this template is to make the wikicode more comprehensible by avoiding QID codes, which substitution counteracts.
Other ways of getting the QID
[sửa mã nguồn]Invoking these modules may also provide the QID for a certain Wikipedia page title:
{{#invoke:wd|label|raw|page=Mars (mythology)}}→{{#invoke:WikidataIB|getEntityFromTitle|Mars (mythology)}}→
but they do not follow redirects.
The following module provides the page title of a redirect destination:
{{#invoke:Redirect|main|Universes}} → Universes
See also
[sửa mã nguồn]- {{Area WD}}
- {{Population WD}}
- {{Popdens WD}}
- {{Label}}, the inverse template