Similar to T110683, there are some cases where it would be convenient to get the wikidata item ID of the parser context page in wiki markup. For example, a graph could use ID as a parameter to geoshapes service to get the outline of the current geographical object (eg city), or as a parameter to a sparql query.
Description
Related Objects
- Mentioned In
- T296549: A parser function for statement value's item ID
- Mentioned Here
- T349571: Create magic word for Wikibase item id
T142093: Decide how to do usage tracking for strings used to lookup entities (page titles, external ids, …)
T133498: Detect and extend known title <-> entity links in a semi-automatic way
T110683: [Story] Add convenience method in lua that gives the ItemId of the connected page
Event Timeline
Parser functions usually require some parameters. I think a magic word (like {{WBREPONAME}}) fits better. Could be for instance {{ITEMID}} or {{ENTITYID}}.
I think we should do the parser function, not a magic keyword. This way we can expand it to do a page lookup. For example, {{ ENTITYID | United States }} is replaced with Q30. The optional first parameter would be the valid page title, as parsed by the local wiki. This will also allow us to easily do {{ ENTITYID | en:United States }} in another Wikipedia language, and still get Q30.
For getting item ID from arbitrary page names see also T133498: Detect and extend known title <-> entity links in a semi-automatic way.
Both sound ok to me, maybe I lean a little towards itemid. A more verbose form like wikibase-itemid probably doesn't make to much sense, does it?
This would probably require T142093: Decide how to do usage tracking for strings used to lookup entities (page titles, external ids, …) to be implemented. We could probably start with a parser function that doesn't take any arguments and then extend upon that, if we can/ want to.
Is there any progress with this feature? Users would really like to use templates like population history -- where users would just place it on the page, instead of requiring a Lua module to get the ID and use tag expansion into wiki markup.
Why don't you use [[https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua#mw.wikibase.getEntityIdForCurrentPage|mw.wikibase.getEntityIdForCurrentPage]] for that? If it's not meant to use the entity id of the current page, how would you know the title of the target page?
@hoo, thanks, I know I can use Lua to get the Wikidata ID, but this means that instead of simply copying one template like this one to all the different wikis, the community would have to copy at least two - the template plus the Lua module, and keep them in sync. Having a wikimarkup to extract at least the current Wikidata ID would mean that only the template would need to be copied.
I propose {{WIKIBASEITEMID}} magic word. Like {{PAGEID}}, {{PAGEID:page name}}. See also T349571.
This has nothing to do with https://www.mediawiki.org/wiki/Extension:ParserFunctions (or https://www.mediawiki.org/wiki/Extension:Variables)
@Pppery What would be the correct project? What project deals with the {{PAGEID}} magic word? This is not about Wikidata, this is about magic words and page properties on Wikipedia. No one seems to deal with this feature request since 2016. Could you help please?
MediaWiki-extensions-WikibaseClient is the correct project. This code would be added to https://www.mediawiki.org/wiki/Extension:Wikibase_Client if someone (who won't be me) were to implement it. MediaWiki-Parser is IMO also wrong, but not so wrong that I am going to remove it.
Magic words are not Wikibase client. This a Wikipedia pageprops. See T349571 for links. Could someone add the right project and assign the task?
{ "batchcomplete": true, "query": { "pages": [ { "pageid": 51046741, "ns": 0, "title": "Kofoworola Abeni Pratt", "pageprops": { "defaultsort": "Pratt, Kofoworola Abeni", "page_image": "Kofoworola_Abeni_Pratt.jpg", "wikibase-shortdesc": "20th-century Nigerian nurse; first black Chief Nursing Officer of Nigeria", "wikibase_item": "Q25796287" } } ] } }
I suspect that there is a table with page properties. As I see, it is already integrated, just needs a magic word like {{WIKIBASEITEMID}}.
You can see it here:
select * from page_props where pp_propname = 'wikibase_item' limit 100