Extension:RemoveSubpagestr

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
removeSubpagestr

Release status: beta

Implementation Skin
Description Remove links from certain subpages back to their root page.
Author(s) Matthew Vickery
Last version 0.1 (14/06/07)
MediaWiki 1.10
License No license specified
Download copy the code form here
Parameters

$wgNoSubpagestr

Hooks used
SkinTemplateOutputPageBeforeExec

Check usage (experimental)

Contents

[edit] What can this extension do?

Remove links from certain subpages back to their root page

[edit] Usage

If you create your own navigation at the top of a page and its subpages you may not want the automatically generated links to the root page to appear on the subpages. This extension allows you to define in your LocalSettings.php file a list of pages whose subpages should not link back to them.

[edit] Installation

  • Copy removeSubpagestr.php to your extensions folder

[edit] Parameters

$wgNoSubpagestr - an array of page titles whose subpage should not link back

[edit] Changes to LocalSettings.php

  • Add an array of page titles as described above
  • include the extension at the bottom of the page
$wgNoSubpagestr = array(
        'My User Page', 
        'Another parent page',  
) ;
 
require_once("$IP/extensions/removeSubpagestr.php");

[edit] Code

<?php
/**
 * Remove links from certain subpages back to their root page
 *
 * Installation: Copy removeSubpagestr.php to your extension folder and add
 * require_once($IP."/extensions/removeSubpagestr.php");
 * to your LocalSettings.php
 *
 * @author Matthew Vickery
 * @version 1.0
 */
 
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'removeSubpagestr';
 
function removeSubpagestr( $skin, $template ) {
 
                // The OutputPage Object used below to get the subtitle
                global $wgOut ;
 
                // Global array of root pages whose subpages should not have links back to the root page
                // Defined in LocalSettings.php 
                global $wgNoSubpagestr ;
 
                // Grab the root page title from the current page title
                $pages = explode('/', $skin->mTitle->getText()) ;
                $rootPage = $pages[0] ;
 
                // check if the root page's subpages should have Subpagestr links back to it
                if (in_array($rootPage, $wgNoSubpagestr)) {
                        $template->set(
                                'subtitle', 
                                $wgOut->getSubtitle()
                        );
                }
 
                return true;
}
 
$wgExtensionCredits['other'][] = array(
        'name' => 'removeSubpagestr',
        'version' => '0.1',
        'author' => 'Matthew Vickery',
        'url' => 'http://www.mediawiki.org/wiki/Extension:RemoveSubpagestr',
        'description' => 'Remove links from certain subpages back to their root page'
);


[edit] See also

[edit] Other extensions by Mattvick

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox