Page MenuHomePhabricator

Add parser function for associated wikidata item ID
Open, Needs TriagePublic

Description

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.

Event Timeline

Yurik created this task.Aug 2 2016, 10:58 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 2 2016, 10:58 AM

Ok from my side. Ideas for a name?

Parser functions usually require some parameters. I think a magic word (like {{WBREPONAME}}) fits better. Could be for instance {{ITEMID}} or {{ENTITYID}}.

Yurik added a comment.Aug 3 2016, 8:29 AM

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.

This comment was removed by Bugreporter.
hoo added a comment.Aug 4 2016, 2:51 PM

[…] Could be for instance {{ITEMID}} or {{ENTITYID}}.

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?

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.

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.

Yurik added a comment.Nov 26 2016, 2:35 AM

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.

hoo added a comment.Nov 27 2016, 5:50 PM

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 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?

Yurik added a comment.Nov 27 2016, 6:36 PM

@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.