Reputation: 43
I've got a MediaWiki site and I would like to add a tab with a very simple "read article" functionality (without any edit/comment options). I followed the manual and tried to create a namespace for it, but it still doesn't work.
The snippet from LocalSettings.php looks like this:
define("NS_ARTICLE", 500);
$wgExtraNamespaces[NS_ARTICLE] = "Article";
$wgNamespaceProtection[NS_ARTICLE] = array( '' );
$wgNamespacesWithSubpages[NS_ARTICLE] = true;
$wgContentNamespaces[] = NS_ARTICLE;
I created new methods in Title.php:
public function getReadPage() {
return Title::makeTitle( MWNamespace::getRead( NS_ARTICLE ), $this->getDBkey() );
}
In Namespace.php:
public static function getRead( $index ) {
self::isMethodValidFor( $index, __METHOD__ );
return self::isTalk( $index )
? $index
: $index + 1;
}
And in SkinTemplate.php:
$readPage = $title->getReadPage();
$content_navigation['namespaces']['article']['class'] = 'selected';
$content_navigation['namespaces']['article']['text'] = 'Article';
$content_navigation['namespaces']['article']['href'] = $readPage;
$content_navigation['namespaces']['article']['primary'] = true;
$content_navigation['namespaces']['article']['context'] = 'subject';
The Tab appeared, but it links to ":Title" instead of "Article:Title". If I look for "Article:Title" page, the following message appears:
There is currently no text in this page. You can search for this page title in other pages, search the related logs, or edit this page.
Any ideas?
Upvotes: 3
Views: 404
Reputation: 3547
Don't touch the MediaWiki sources or you'll have to redo the same thing each time you upgrade. Tab manipulation is doable with hooks, e.g. SkinTemplateNavigation.
Upvotes: 2