WhatLinksHereFooter

Aus Free Software
Zur Navigation springen Zur Suche springen

WhatLinksHereFooter does, what its name says: It displays a list of links (similar to Special:Whatlinkshere) at the bottom of each page. The list can be shown only on pages in certain namespaces or that are in certain categories, the same restrictions can be applied to the pages listed.

Installation

Straight forward, as with most other extensions. Just drop WhatLinksHereFooter.php (read source or download tar.gz) in your extensions directory and add the following line in your LocalSettings.php:

require_once ("$IP/extensions/WhatLinksHereFooter.php");
$WlhF_enable = true;

Configuration

The behaviour of the extension is very customizable, however, it was written with what I had in mind of doing with it. Customizing the code to fit other needs shouldn't be that hard, though.

General configuration

First you have to tell the extension, what the heading should look like, what the text shown before the list of links should be and what the text if no pages are found should be:

$WlhF_header = "=== WhatLinksHere? ===";
$WlhF_success = "These Pages link to '''{{PAGENAME}}''':";
$WlhF_error = "Currently no articles link here!";

The $WlhF_header variable requires some special attention: In this case the footer will be its own chapter, even showing up in the table of contents. The level you specify here (number of '=') will also be used as the level of the final chapter.

The text of all of these variables will be directly appended to the text that is in the database, later interpreted by the Wikiparser. As shown above, you might want to include both templates and magic words, as well as any other MediaWiki syntax (including <br />).
The one thing that will not work, is adding a page to a category through this extension, since the database itself is of course not modified by this extension. The Page itself will say its in the category, but the category page will not include these pages.

Where this extension should be viewed

Per default, the Footer is shown on all pages. You can, however, define namespaces and/or categories, in which the Footer is displayed. If you specify either of the following two variables, the footer will only appear on pages that are in the specified namespaces/categories:

$WlhF_Namespaces = array (0, 1, 2, 3, 4, 5, 6);
$WlhF_Categories = array ('Test', 'Hugo');

When specifying multiple namespaces/categories, these are OR'ed together, meaning that the page has to be in only one of the categories to match, but if you specify both namespaces and categories, these will be AND'ed together. In the above example, a page will have a footer if it is in any of the listed namespaces and is in any of the listed categories. If you only specify namespaces (or categories) the article will have a footer if it is in any of the namespaces (categories). So a page in namespace 0 that is in the category "Test" will have a footer, but a page in namespace 7 will have no footer (regardless of what categories it is in) and a page that is in neither the category "Test" nor the category "Hugo" won't have a footer either.

Both variables are optional, so if you want the footer to appear in all pages and not worry about namespaces or categories, you can simply omit these variables.

What pages are listed

Per default, all pages that link to the current page are listed in the footer. You may want to specify, in what namespaces and/or categories a page should be to be included. Similar to the above, if you specify either of the following two variables, pages will only be included if they are in any of the namespaces/categories and if you specify both, pages must be in both one of the namespaces and one of the categories.

$WlhF_ListNamespaces = array(0, 1, 2);
$WlhF_ListCategories = array('foo', 'bar');


So basically, there is always a logical AND between categories and namespaces. As a logical expression this would look like this:

(ns1 OR ns2 OR ... OR nsN) AND (cat1 OR cat2 OR ... OR catN)

This fits our needs very well, but may not fit your needs. I've written the extension with that in mind, so it is very easy to get the opposite behaviour out of it. All it takes is negating a vew regular expressions. You may want to read the sourcecode on this one ;-)

Licence

The code is licenced under the GNU GPL v2, or any later version. See the Free Software Foundation for more details on the licence.


Please note that the chapter below is an example of this extension, as well as the PreloadUploadForm extension, in action: