Page MenuHomePhabricator

Variable (magic word) e.g. {{ARTICLELINKSONPAGE}} to assist with reports and comparative backlogs
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
I would like a simple way to get a count of unique article links on a page, usually a generated report. A cached variable like {{ARTICLELINKSONPAGE: pagename}} would be called to retrieve this value, which can then be used in comparative backlog listings, such as in WikiProjects or other group efforts.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
The problem is that seemingly every way available to get at this number is kludgy:

  • A {{Database report}} can be run with very simple SQL but its result often will lag the change in results of the page it is analyzing. That is, the reports cannot be run in tandem (as of September 5, 2025). Even running the count report on the same page as the report it's analyzing doesn't work unless one manually twice requests the page's reports to be generated.
  • A bot accessing the API to gather and count the mainspace links on a page is possible but this of course requires writing a bot or asking one to be written. That is a lot of work/hassle to get at a simple value.
  • Either approach above involves depositing the value somewhere to be transcluded separately, when a single call to get the links count would be obviously more convenient.

Benefits (why should this be implemented?):

For the sake of reports, a variable like this would be useful for the sake of demonstrating the relative weight of issues in comparative concerns (e.g. number of orphaned/isolated articles vs. number of articles with citation errors), demonstrating progress toward a goal of addressing issues, and/or administering backlogs of listed issues (and knowing if there is a backlog). Having a shortcut to a number showing how many unique articles are linked in a report would enhance productivity in these scenarios.

Event Timeline

Do you want the number of links, or a list of links themselves?

I guess the latter could be used to produce the former with a parser function to count the number of items in the array.

As for the name, {{#pagelinks:}} would be better and the more modern style of using parser functions beginning with #.

I'm looking for the number of links on a page that go to articles (mainspace), but I would be fine with something that can return the value for any desired namespace. I need the number for issues backlogs and comparisons between them (to help project participants better decide what to work on), and to determine when a type of issue no longer has a backlog. I already have the lists in the reports themselves.

I was thinking of this as a statistics variable rather than a parser function, but I'm willing to abide by the judgment of who may develop this.

If you want the number of links to a page, as detailed in [[Special:WhatLinksHere]], it probably should be {{#numberoflinkshere:}}

That's not what I'm asking for. I'm asking for the number of links that are linked on a page, not the incoming links.

I have modified my previous comment to clarify

So {{#numberoflinksfrom:pagename}} then?

Could you strengthen the use case explanation?

It is for developers to decide how they would like to implement this. As long as it returns the value I'm seeking, I'm good. I merely offered a suggestion as to how to do it.

If anyone has specific questions that leads to improving the use cases, I would be happy to address them. Without such input, I have no idea what would "strengthen" them.

Upon requesting a template/module on enwiki, I realized my wish could be simplified to the following:

Akin to {{NUMBEROFSECTIONS}}, I'd like to have a template called {{NUMBEROFUNIQUELINKS}}.

To get the number of unique mainspace links on a page, in this example, a WikiProject report page, the code would look like {{NUMBEROFUNIQUELINKS|Wikipedia:WikiProject Kentucky/OldIssues|ns=0}}

The default for ns would be for "all namespaces", returning the number of all unique pages that are linked.

My particular need for this is to obtain the number of unique articles (in the form of internal links) returned in the results of a {{Database report}} on a page. I use such reports to create specialized lists of issues in articles. With the number returned, I can use it to demonstrate when a backlog exists, or for comparing the number of articles affected between different types of issues (useful for backlog ordering), or for comparing the number of articles affected by a particular type of issue between different WikiProjects.

I assume this will require an underlying module.