Topic on Project:Support desk

A magic word that indicates how many pages link to a specific page

11
Guycn2 (talkcontribs)

Is there any magic word that can check how many pages are in the "What links here" list of a given page?

For comparison, there is a magic word that indicates how many pages are in a specific category:

{{PAGESINCATEGORY:Support desk archives}}40

Is there any way to make the software show the number of pages that link to a specific page, similar to showing the number of pages that appear in a category?

If there isn't any magic word that can do it, is it possible to make the software view the number of pages that "link here" using a script, module or something similar?

FriedhelmW (talkcontribs)

What is the use case of this?

Guycn2 (talkcontribs)

@FriedhelmW|FriedhelmW:

On MediaWiki:Deletedtext (on Hebrew Wikibooks, but it doesn't matter), I want the system to show a warning only if there are pages that link to the deleted page.

For example, if the magic word {{NUMBEROFLINKINGPAGES:page-name}} returned the number of pages that link to a page, I could use the following code on MediaWiki:Deletedtext:

{{#ifeq:{{NUMBEROFLINKINGPAGES:{{FULLPAGENAME}}}}|0||

ATTENTION! There are other pages that link to the page you have deleted:
{{Special:WhatLinksHere/{{FULLPAGENAME}}}}

}}

The code above actually checks how many pages link to the current page using the imaginary magic word {{NUMBEROFLINKINGPAGES:page-name}}. If the number is 0 (i.e., there are NO linking pages), then the warning is NOT displayed. If the number is different from 0 (i.e., there ARE linking pages), then the warning IS displayed.

Currently, I cannot use such a trick, because I don't know any magic word that returns the number of pages linking to a page.

AhmadF.Cheema (talkcontribs)
Guycn2 (talkcontribs)
AhmadF.Cheema (talkcontribs)
Guycn2 (talkcontribs)
AhmadF.Cheema (talkcontribs)

I think what you want can be done by using: "#ifeq" to check for the condition of whether there were any linked pages. If there were, the message gets shown, if not the message is "blanked out" (I think this is what you were talking about from the start).

To check the condition, one way of doing it would be to create a template that does this.

The template could be something like to include "{{#dpl:linksto = pagename}}" (Help:What_links_here).

"{{#dpl: " needs Extension:DynamicPageList3, this function is detailed here: Usage Philosophy and Overview.

The template will check if the "{{#dpl:linksto = pagename}}" gives an empty value or not for the current page. If the value is empty, result is "0" otherwise "1". This template is then included in the MediaWiki:Deletedtext, which according to the result given by the previous template shows either the message or the message gets "blanked out".

By-the-way, there is also an extension (Extension:BackLinksFunctions) that could do all this too, but it doesn't seem to have been maintained; maybe it still might work for you.

Guycn2 (talkcontribs)

Thank you for the detailed answer.

Are the extensions you mentioned available to use on Wikimedia projects?

AhmadF.Cheema (talkcontribs)
Guycn2 (talkcontribs)

Thank you.

Reply to "A magic word that indicates how many pages link to a specific page"