On Sun, Feb 6, 2011 at 4:30 PM, David Gerard dgerard@gmail.com wrote:
Here's an interesting question. Is there any way for Special:WhatLinksHere to distinguish between links from a template rather than links from the actual article text? I presume at present it all just goes into a links table generated on save, and can't be distinguished ...
Long story short, there's no good way to distinguish them due to combination of 1) it's hard to define the actual problem domain and 2) the links tables as they are today are not rich enough to distinguish the various cases after the fact.
It's not very clear what "links from a template" mean, exactly; there are several possibilities: * the literal text [[Foobar]] appears in template code that gets expanded into the calling page, but does not appear in the calling page's source * the literal text [[Foobar]] appears in a template parameter passed from the calling page to the template, which then expands it into the calling page's own context. It would not become a link unless the template were there, but the entire link appears in the calling page's source (example: anything linked in freetext parameters to a citation or infobox template) * the template constructs a link with some parameter, say [[{{{something}}}]] which creates a link [[Foobar]] that exists by itself in neither the calling page nor the template, but whose target is provided by the calling page (example: lots and lots of infoboxes and such) * the template constructs a link with some parameter, say [[Wikipedia:List_of_requests/{{{something}}}]] which creates a link that exists by itself in neither the calling page nor the template, but whose target is influenced in some way by the calling page (example: lots of helper templates for discussion chunks) * the template constructs a link with some other piece of information, perhaps a parser function, that can't clearly be traced from the calling page (though it might be related to the calling page, such as pulling its page name.)
See also old notes on https://bugzilla.wikimedia.org/show_bug.cgi?id=5388
I get the impression that the most desired case is to help humans to identify the simplest case at the top of the list: literal links that appear in the template's freeform body text as included at template expansion time.
The pagelinks table doesn't store the needed information; even looking for literal links from an existing template page, what you'll actually see recorded is what appears in the template page parsed as its *own* page, which might be a big giant documentation page done with <includeonly> and friends. You may also legitimately have links that appear in both the calling page's body *and* in the template, and probably wouldn't want to filter those out.
More information would need to be saved from the parser into the link tables... it may, or may not, be possible in the present parser system to distinguish some of these cases when actually finding links and expanding things, and then find some way to record in the links tables what source(s) the link came from.
-- brion