We are developing a wiki for social services documentation, and I'm hoping to use subpages as this will in effect have pages with the same name:-
children with disabilities/forms child protection/forms etc.
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.
I tried adding the following function to monobook.php, which will change the displayed title to just be the bit after the last /
function chop_title($show) { if(strrpos($show,'/')) { $show = substr(strrchr($show,'/'),1);}; return($show); }
and changed the line <h1 class="firstHeading"><?php $this->text('title') ?></h1> to <h1 class="firstHeading"><?php chop_title($this->text('title')) ?></h1>
I've tested the the function outside the monobook.php and it works a expected but id doesn't work in situ (has no effect on the displayed title)
Any comments ?
Ta
JohnToi
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.
This works great with version 1.6.9 on the systems we are running.
Many thanks
John
Juliano F. Ravasi wrote:
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.
mediawiki-l@lists.wikimedia.org