Aus Free Software
Version vom 14. November 2014, 20:05 Uhr von Mati (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png

Release status: stable

Implementation Special page
Description This special page allows you to view resources attached to a given page. This extension is part of the PerPageResources project.
Author(s) Mathias Ertl (Mati talk)
Version 1.5.2 (2012-10-07)
MediaWiki 1.19 or later
License GPL v3 or any later version.
Download see Download
Parameters $wgResourcesShowPages, $wgResourcesShowSubpages, $wgResourcesShowLinks, $wgResourcesDirectFileLinks, $wgResourcesSubpagesIncludeRedirects, $wgResourcesAddInfos, $wgResourcesTabs, $wgAddResourceTab, $wgResourcesCSSpath
Example try this page
Hooks used


This Extension, part of the PerPageResources-Project, enables you to view Resources attached to a given page. Simply call the provided special page (Special:Resources) with the page-name (as provided by Resources) as parameter and the page will give you a category-style listing of all resources associated with that page. Such resources can be Files, Subpages or links to external websites. They can easily be added with Special:AddResource, but any kind of resource can also be added by hand. This extension can also be used to display a tab to Special:Resources next to the discussion-tab.


The source code of this extension is managed on GitHub. You can find the repository at mathiasertl/Resources. To get the most recent version of this extension, fetch the current HEAD:

git clone Resources

Older versions are marked as tags, you can view available tags with git tag -l and move back to the current HEAD with git checkout <tag-name>. Versions for older versions of MediaWiki, if available, are managed as branches, use git branch and git checkout <branch> to move to a specific branch. To move back to the newest version, use git checkout master.

Note that GitHub allows you to download older different commits as tarball if you do not want to install git.

Installation & Configuration

Simply download all three files (Resources.php, Resources.i18n.php and SpecialResources.php) into you extensions-directory, preferably into their own directory and include Resources.php in your LocalSettings.php:

# Resources extension
Default Settings

The extension is very configurable, the code below gives you a complete example of all configuration-variables set to their defaults:

    $wgResourcesShowPages = true;
    $wgResourcesShowSubpages = true;
    $wgResourcesShowLinks = true; #this also requires $wgEnableExternalRedirects=true
    $wgResourcesDirectFileLinks = false;
    $wgResourcesSubpagesIncludeRedirects == false; # note that this will never include broken redirects
    $wgResourcesAddInfos = false;
    $wgResourcesTabs = true;
    $wgAddResourceTab = true;
Settings in detail

The variables should be self-explanatory, but heres a specification anyway:

Whether or not files linking to the given page should be included.
Whether or not subpages of the given page should be included.
Whether or not external redirects (that are subpages of the given page) should be included
Whether or not Files linking here should be directly linked to (true) or if their page in the media-namespaces should be linked (false).
Whether or not we should include (working) redirects.
Whether or not we should include comments (i.e. page-length, file-size, etc.) for each resource found.
Whether to display a tab to the resources-page
Whether to display a tab to the AddResources page if Special:Resources is currently viewed.;
if your extension is installed in an unusual location, or you want to have the CSS-file elsewhere, you can configure the path to it with this variable.
CSS for additional tabs

On default, the new tab is in the wrong position, the resources tab has a large space to the discussion tab and is very close to the edit-tab. To fix this, you can add a tiny bit of CSS to MediaWiki:Common.css:

/* This is for the Resources Tab. */
li#ca-view-resources {
	margin-left: -1.3em;
	margin-right: 1.6em;

Once that is done (and the cache is regenerated) the tabs should be in the right position (like in this wiki).


  • Fix tabs for all skins
  • code-style cleanup
  • Add compatibility with MediaWiki 1.19.
  • Minimal required version is now changed to 1.19.
  • Implement limited functionality for the new 'Vector' skin. So far the resources tab can only be added to the normal pages, not to the special page itself, as there is no hook called in this case
  • Display the number of resources in the tab
  • Updated url of the extension to this page
  • This version should work with MediaWiki 1.11.1 or later.
  • The CSS required for the resources-tab must now be included in MediaWiki:Common.css (or Monobook.css). This should cut the load-time somewhat, because Common.css is included anyway.
  • The special page now shows another chapter that lists pages that redirect here. This chapter is only shown when there are actually any redirects here.
  • Massively optimized algorithms. getLinks now takes 1/6 the time it did before, getFiles is now 20% faster.
  • Each of getFiles, getLinks and getSubpages now takes a second, optional, parmater $count. If true, the function will do a SELECT count(*) instead of multiple fields. After the SQL-Query is made, it returns right away with the count returned by it. This lowers memory-consumption and Speeds up every such function-call by a factor of 15 or so.
  • As a result, getResourceListCount is now 60 times faster (really!). This alone speeds up load-times of entire pages by up to 200ms.
  • Fixed a nasty transient bug that multiple pages might have the same sortkey (and thus, one disappears in the Resources-view). Every sortkey now has the page_id (which is the key of the MySQL-Table) appended.
  • The target of the links in the tabs is now generated by getPrefixedDBkey instead of getPrefixedText. This is a bit faster.
  • updated to work with all wiki/user language combinations
  • if no parameter is given and $wgResourcesCategory is defined, the special page displays all pages in that category. This is achieved using the DynamicPageList-Extension. This is a rather quick hack and should be done in a better way.
  • various java-script-variables that where used by Common.js where removed.
  • removed a useless require_once (for ExternalRedirects)
  • renamed various functions to conform to standards (efResources...)
  • A very specific fix for our needs: ä/ö/ü/Ä/Ö/Ü are now sorted as ae/oe/ue/Ae/Oe/Ue.
  • The CSS is now added automatically.

this is a major upgrade:

  • This extension can now display a tab to the </nowiki>Special:Resources/Resources</nowiki> next to the discussion header. It is automatically red, if there are no resources for this page.
    • This deprecates Common.js and AddBasePage. The tab-functionality is now better integrated and has more features
    • for this to really look good, you need two lines of CSS (see above)
    • new i18n message 'resourcesTab' is used for the tab-text
  • $wgAddResourceTab is set to true (see AddResource-extension) a tab for the AddResource-Page is also displayed if Special:Resource is currently viewed.
  • Now use $wgOut->setPagetitle() to set the page title, causing it to be also displayed in the <title> html-tag.
    • This deprecates some of the css that was previously used to hide the real header
  • Updated to work with MediaWiki 1.11.1 and later by fixing LanguageGetSpecialPageAliases (This was a typo in 1.11.0, see Bug 11462)
  • Updated link to this page (This wiki now uses Very short URLs)
  • fixed a bug in the english translation that caused the creation of a broken link if no resources where found.
  • first version documented here.


Some features of this special page are not yet implemented:

  • Some Request-parameters (?showFiles etc.)
  • For now, this extension is only able to find articles in the media-namespace linking here (the files), which is a hardcoded limitation which could be overcome easily. The variable to configure these namespaces is already in place (but nun functional) and is called $wgResourcesNamespaces.
  • The extension could use SimilarNamedArticles to find all resources for pages with a similar title if the page itself doesn't exist.
  • sortkey could be changeable, i.e. sort by last-change or so...


GPL v3 or any later version.