Extension:RandomPages

Random Pages returns one or more randomly selected pages.

Overview
License: GPL-v3, see COPYING file for full licensing information

Original version 0.2 doesn't work with mediawiki 1.25.3 (Original URL: http://locknet.ro/archive/2008-03-21-mediawiki-random-pages.html ). Updated version below which works. Install/use has not changed w/ this new version (0.3)

Source
* * Gets 10 random pages from the global namespace with 10 levels of style * * @param $text string, it should be null * @param $params array, additional parameters passed as attributes to randompages tag * @param $parser Parser, the Wiki Parser Object */ function aoRandomPagesHook($text, $params, $parser) { global $wgDBprefix; // prevent caching for this wiki page $parser->disableCache; // get parameters $limit = isset($params['limit']) ? (int)$params['limit'] : 150; $namespaced = isset($params['namespace']) ? $params['namespace'] == 'true' : false; $levels = isset($params['levels']) ? (int)$params['levels'] : 5; // build sql query $sql = sprintf('select * from %spage where', $wgDBprefix); $sql .= $namespaced ? ' page_namespace = 0 ' : ' 1=1 '; $sql .= sprintf('order by rand limit %d', $limit); // execute that. $dbr = wfGetDB( DB_SLAVE ); $rs = $dbr->query( $sql ); $buff = ' '; while( $row = $rs->fetchObject( $rs ) ) { $buff .= ''; #KKM commnet out as it is now working. https://www.mediawiki.org/wiki/Extension_talk:SearchBox $title = Title::makeTitleSafe($row->page_namespace, $row->page_title); // manually call __toString for php < 5.2 $buff .= sprintf('%s', $title->getLocalURL, $title->__toString, $title->__toString); #$buff .= sprintf('%s', $title->escapeLocalURL, $title->__toString, $title->__toString); $buff .= ' '; } return $buff. ' '; }

Install
Unpack the zip file to your MediaWiki extension folder.

Then you can enable the extension in your LocalSettings.php:

Then go edit a page and use the &lt;randompages /&gt; tag.

Installation can be verified through the Special:Version page on the wiki.

Usage
RandomPages adds a new MediaWiki wiki parser tag: &lt;randompages /&gt;

Available options:


 * limit int, to control how many links should be fetched randomly from the database, defaults to 150
 * namespace bool, true to restrict only to the global namspace, defaults to false
 * levels int, levels of CSS applyed to each entry, defaluts to 5

&lt;randompages limit="10" namespace="true" levels="10" /&gt;

Gets 10 random pages from the global namespace with 10 levels of style

Development
http://gitorious.org/projects/randompages

Feature Requests / Bugs

 * Contact developer at: http://locknet.ro/