Minecraft Wiki

The Minecraft Wiki has moved from Fandom; see the linked discussion page for details.

READ MORE

Minecraft Wiki
Advertisement

Here I keep my various chatlogs, mainly from #Minecraft. Kept for archiving purposes and whatnot.


Exclude categories from random page extension[]

Set to exclude pages in the Projects category, add additional categories seperated by commas.

<?php $wgHooks['SpecialRandomGetRandomTitle'][] = 'randomExcludeCategories';

function randomExcludeCategories( &$randstr, &$isRedir, &$namespaces, &$extra, &$title ) {

       $categoriesToExclude = array('Projects');
       
       if( count( $categoriesToExclude ) == 1 ) {
               $extra[] = "NOT EXISTS (SELECT 1 FROM categorylinks WHERE cl_from = page_id AND cl_to = ".$categoriesToExclude[0].")";
       } elseif( count( $categoriesToExclude ) > 1 ) {
               $extra[] = "NOT EXISTS (SELECT 1 FROM categorylinks WHERE cl_from = page_id AND cl_to IN ('".implode("','",$categoriesToExclude)."'))";
       }
       return true;

}

?>

Advertisement