[Mediawiki-l] Title for subpages

Juliano F. Ravasi ml at juliano.info
Tue Jan 23 20:43:53 UTC 2007


John Moorhouse wrote:
> The only comment we have had is that people don't like the page title 
> being the full form as you know the parent pages anyway as they are 
> listed in the breadcrumbs.

This is what I did to achieve a similar result, skin-agnostic:


Index: includes/Article.php
===================================================================
--- includes/Article.php	(revision 145)
+++ includes/Article.php	(revision 146)
@@ -607,6 +607,7 @@
 		global $wgUser, $wgOut, $wgRequest, $wgContLang;
 		global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
 		global $wgUseTrackbacks, $wgNamespaceRobotPolicies;
+		global $wgNamespacesWithSubpages, $wgNamespacesToOmitParents;
 		$sk = $wgUser->getSkin();

 		wfProfileIn( __METHOD__ );
@@ -813,7 +814,18 @@
 		/* title may have been set from the cache */
 		$t = $wgOut->getPageTitle();
 		if( empty( $t ) ) {
-			$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+			/*
+			* -- jr - Feb 22, 2006
+			* Allow short page titles.
+			*/
+			if ( !empty($wgNamespacesWithSubpages[$this->mTitle->getNamespace()]) &&
+				!empty($wgNamespacesToOmitParents[$this->mTitle->getNamespace()]) ) {
+				$titleText = $this->mTitle->getPrefixedText();
+				$exploded = explode( '/', $titleText );
+				$wgOut->setPageTitle( $exploded[ count($exploded)-1 ] );
+			} else {
+				$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+			}
 		}

 		# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
Index: includes/DefaultSettings-Jr.php
===================================================================
--- includes/DefaultSettings-Jr.php	(revision 145)
+++ includes/DefaultSettings-Jr.php	(revision 146)
@@ -12,4 +12,9 @@
  */
 $wgCategoryIndexColumns = 3;

+/**
+ * Namespaces whose article titles won't carry parent titles.
+ */
+$wgNamespacesToOmitParents = array();
+
 ?>



The last change should probably go to DefaultSettings.php in your case.
Add namespaces that you want this behavior to both
$wgNamespacesWithSubpages and $wgNamespacesToOmitParents.


-- 
Juliano F. Ravasi
5105 46CC B2B7 F0CD 5F47 E740 72CA 54F4 DF37 9E96

"A candle loses nothing by lighting another candle."
    -- Erin Majors

* NOTE: To contact me directly, replace "ml" with
"contact" on my e-mail address.

* AVISO: Para me contatar diretamente, troque "ml"
por "contact" no endereço de e-mail.




More information about the MediaWiki-l mailing list