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.02', );

function parentpagelink($editpage) { // EditFormPreloadText global $wgOut; $wgOut->enableClientCache(false); # Check for no preview and blank page if (!$editpage->preview       && !$editpage->mArticle->mContentLoaded) { $title = $editpage->getTitle; $artID = $title->getArticleID; $dbr = wfGetDB( DB_SLAVE ); # select to grab parent id		$res = $dbr->select(				'pagelinks',				array( 'pl_from' ),				array('pl_title' => $title),				__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) ?>