Open main menu

Extension:RatePage

MediaWiki extensions manual
OOjs UI icon advanced.svg
RatePage
Release status: beta
RatePage example.png
Implementation Database , User interface
Description Enables readers to rate pages on a wiki
Author(s) Ostrzyciel, Polskacafe (Ostrzycieltalk)
Latest version continuous updates
Compatibility policy master
MediaWiki 1.32+
PHP 7.0+
Database changes Yes
License MIT License
Download
Example An article on Nonsensopedia with rating widget in the sidebar
Translate the RatePage extension if it is available at translatewiki.net
Check usage and version matrix.

The RatePage extension enables readers to rate pages on a wiki.

On desktop skins (currently tested under Monobook, Vector and Timeless) it adds a widget in the sidebar that allows readers to choose any of five available ratings for a page. The extension also works on Minerva, adding the widget in the footer. The extension is configurable and allows for disabling of the default frontend and potentially using a different one. The main functionality is provided via an API module and the data is stored in a custom database table (ratepage_vote).

InstallationEdit

  • Download and place the file(s) in a directory called RatePage in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'RatePage' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

ConfigurationEdit

$wgRPRatingAllowedNamespaces
Array of namespace IDs that are allowed to be rated. Default is null, which allows all namespaces. An empty array means no namespaces are allowed.
$wgRPRatingPageBlacklist
Array of page titles that are not allowed to be rated. Default is an empty array. You may want to add the main page to the blacklist.
$wgRPSidebarPosition
Integer indicating where in the sidebar should the widget be placed (one-based index). Default is 2, which places the widget directly under the first (default) sidebar section.
$wgRPFrontendEnabled
Bool indicating whether the default frontend module should be loaded. Default is true. Disable this if you want to write your own custom JS script for voting.
$wgRPAddSidebarSection
Bool indicating whether to add the default sidebar section for the widget. Default is true. Disable this if you want to write your own custom JS script for voting and you don't want to rely on the extension adding a section to the sidebar.
$wgRPRatingMin
Minimal allowed rating. Default is 1. You may want to change that if you decide to remove the default frontend module and write your own that for example allows for only three different ratings.
$wgRPRatingMax
Maximal allowed rating. Default is 5.

Rate limitingEdit

RatePage supports rate limiting for its API. For more information about $wgRateLimits and how to set it up, read Manual:$wgRateLimits, the action key is ratepage.

Sidebar cacheEdit

RatePage does not function properly with sidebar cache enabled. It is disabled by default, but if you have it enabled, you should disable it through the $wgEnableSidebarCache configuration variable.

ContestsEdit

RatePage comes with a simple functionality that lets you set up "contests" during which users vote on pages on your wiki, but these votes are not counted towards the page's general score. They are kept separately from the main score. Currently there is no way to time-limit these contests, this may be added to the extension in the future. A more complex approach to defining contests with dedicated contest pages (like UploadWizard's campaigns) is being considered.

The only way to access the contest feature is to embed a voting widget in a page using the {{#ratepage: }} parser function.

  • First (required) parameter is the title of the page you want to rate.
  • Second (optional) parameter is the contest ID that you want to use. You can use one contest ID for as many pages as you like. A contest ID must only contain digits and lower- or uppercase latin letters. If you don't specify a contest ID, the widget will be linked to the main score of the page.
  • Optional width= parameter can be used to specify the width of the widget on the page.

For example {{#ratepage:Main Page|CONTEST1|width=250px}} will yield a voting widget 250 pixels wide, that will let you rate the Main Page within contest CONTEST1.

APIEdit

RatePage adds one API module that can be used both for voting on pages and retrieving votes that have been added so far.

action = pageratingEdit

Allows users to rate pages and retrieve all votes that have been submitted so far.

Parameters
  • pageid: The id of the page
  • pagetitle: The title of the page (you must specify either pageid or pagetitle
  • answer: Your rating of the page (optional). If you do not specify the answer parameter, the API will just return the current votes.
Example

Rate the Main Page with a 2