Page MenuHomePhabricator

A parser function for statement value's item ID
Open, Needs TriagePublic


Neither #statements nor #property seem to have a method for fetching of a Wikidata item ID in the case that the value requested is a wikibase-item data type. We are stuck retrieving either a formatted item label or a plain text label, even though the item is clearly already being accessed on the backend to retrieve the label, so the item ID must also be being accessed. This is less than useful for template coding, because:

  1. Wikidata labels can change and are not unique. So you can't build template logic around having different behaviors for specific values returned by the parser functions, whereas a Q-id should (in theory) be predictable.
  2. With existing Lua-based templates, there are many use cases where users on other wikis can plug in Wikidata item IDs in order to generate important page content, such as Wikipedia infoboxes or Commons creator and institution templates.

An example use case for the scenario in #2, I would like to store the institution data in a Commons file's P195 statement. If I can retrieve the item ID, I can use it to populate the institution template, like {{institution| {{#itemvalueid:P195|from=M123}} }}. (No opinion on what to call the function.) With #property, I currently can only have the item's plain text label, which doesn't allow me to get the full use out of templates like these.

Also, this would allow us to build more useful templates without the need of Lua infrastructure. Using the above example, if I can get the item ID for a Commons file's P195 statement value, then I can use other functions, such as #statements to query that Wikidata item for other data, such as the institution's associated Commons category, logo, location, etc.

Related to T141864, which also seems to be about the utility of retrieving item IDs for downstream use.