【发布时间】:2013-04-29 08:26:27
【问题描述】:
我有一个 MediaWiki 站点,我想添加一个带有非常简单的“阅读文章”功能的标签(没有任何编辑/评论选项)。我按照手册并尝试为它创建一个命名空间,但它仍然不起作用。
LocalSettings.php 中的 sn-p 如下所示:
define("NS_ARTICLE", 500);
$wgExtraNamespaces[NS_ARTICLE] = "Article";
$wgNamespaceProtection[NS_ARTICLE] = array( '' );
$wgNamespacesWithSubpages[NS_ARTICLE] = true;
$wgContentNamespaces[] = NS_ARTICLE;
我在 Title.php 中创建了新方法:
public function getReadPage() {
return Title::makeTitle( MWNamespace::getRead( NS_ARTICLE ), $this->getDBkey() );
}
在 Namespace.php 中:
public static function getRead( $index ) {
self::isMethodValidFor( $index, __METHOD__ );
return self::isTalk( $index )
? $index
: $index + 1;
}
在 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';
标签出现了,但它链接到“:Title”而不是“Article:Title”。如果我查找“文章:标题”页面,则会出现以下消息:
此页面中目前没有文字。您可以在其他页面搜索此页面标题,搜索相关日志,或编辑此页面。
有什么想法吗?
【问题讨论】:
-
我不确定为此创建命名空间是否有意义,您为什么要这样做?
标签: php tabs namespaces mediawiki