Extension:HideCategorizedOrphans

Category:Extensions which host their code in-wiki Category:Unmaintained extensions#HideCategorizedOrphans Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
HideCategorizedOrphans
Release status: unmaintainedCategory:Unmaintained extensions
Implementation MyWiki Category:Personalization extensions
Description Makes MediaWiki consider pages that belong to a category not be orphans
Author(s) Steven Orvis (Sorvistalk)
Latest version 0.2.0 (2014-06-09)
MediaWiki 1.23+Category:Extensions with manual MediaWiki version
PHP 5.3+
Database changes No
License GNU General Public License 2.0 or later
Download See the code section
Category:All extensionsCategory:Extensions not in ExtensionJson

The HideCategorizedOrphans extension makes MediaWiki consider pages that belong to a category not be orphans. This is useful if you want to link to a category off of a page, but the links to that individual page show up nowhere else.

Installation

Code

HideCategorizedOrphans.php
<?php
/**
 * HideCategoizedOrphans extension
 *
 * For more info see https://mediawiki.org/wiki/Extension:HideCategorizedOrphans
 *
 * @file
 * @ingroup Extensions
 * @author Steven Orvis, 2014
 * @license GNU General Public Licence 2.0 or later
 */

$wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'HideCategorizedOrphans',
        'author' => array(
                'Steven Orvis',
        ),
        'version'  => '0.2.0',
        'url' => 'https://www.mediawiki.org/wiki/Extension:HideCategorizedOrphans',
        'descriptionmsg' => 'Hides orphaned pages that belong to a category',
);

/* Setup */

// Register files
$wgAutoloadClasses['HideCategorizedOrphansHooks'] = __DIR__ . '/HideCategorizedOrphans.hooks.php';

// Register hooks
$wgHooks['LonelyPagesQuery'][] = 'HideCategorizedOrphansHooks::onLonelyPagesQuery';


HideCategorizedOrphans.hooks.php
<?php
/**
 * Hooks for HideCategorizedOrphans extension
 *
 * @file
 * @ingroup Extensions
 */

class HideCategorizedOrphansHooks {

        /**
         * Add condition to LonelyPagesQuery to hide pages in categories
         */
        public static function onLonelyPagesQuery( &$tables, &$conds, &$joinConds) {
                $joinConds['categorylinks'] = array(
                        'LEFT JOIN', array(
                                'cl_from = page_id'
                        )
                );

                $tables[] = 'categorylinks';

                $conds[] = 'cl_from is null';
                return true;
        }
}
Category:All extensions Category:Extensions not in ExtensionJson Category:Extensions not using extension registration Category:Extensions which host their code in-wiki Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:LonelyPagesQuery extensions Category:Personalization extensions Category:Unmaintained extensions