Extension:ParentPageLink

The ParentPageLink extension does a page-link to the parent page upon editing a new page.

Installation
require_once( "$IP/extensions/ParentPageLink.php" );
 * 1) To install the ParentPageLink extension, put the following line in LocalSettings.php

Code


*/ if (!defined('MEDIAWIKI')) { echo << 'ParentPageLink',	'author' => 'Jesse B. Dooley',	'url' => 'http://www.mediawiki.org/wiki/Extension:ParentPageLink',	'description' => 'Adds a Parent Article Link',	'descriptionmsg' => 'parentpagelink-desc',	'version' => '0.03', );

function parentpagelink($editpage) { // EditFormPreloadText global $wgOut;//, $wgDBprefix, $wgDBname, $wgUser, $wgOut;; $wgOut->enableClientCache(false); # Check for no preview and blank page if (!$editpage->preview       && !$editpage->mArticle->mContentLoaded) { $parentID = ""; $parentName = "";

$title = $editpage->getTitle; $dbr = wfGetDB( DB_MASTER ); # replace ' ' with '_' because getTitle doesn't		$title_name = str_replace( " ", "_", $title); # select to grab parent id		$res = $dbr->select(				'pagelinks',				array( 'pl_from' ),				array('pl_title' => $title_name),				__METHOD__,				array( 'ORDER BY' => 'pl_from ASC' )		); # get the $parentID foreach( $res as $row ) { $parentID = $row->pl_from; }

# get the parent title $res = $dbr->select(				'page',				array( 'page_title' ),				array('page_id' => $parentID),				__METHOD__		); foreach( $res as $row ) { $parentName = $row->page_title; }

# Add the parent link, modify the string as needed $editpage->textbox1= "\n\n=Internal Links=\nParent Article: " . $parentName . " "; $editpage->textbox2=$editpage->textbox1; } // end if   return true; } // function parentpagelink($editpage) ?>
 * 1) Does not take spaces or underscore in a page name, fix later!