How do I add Special:PrefixIndex/FULLPAGENAME to the toolbox in my local MediaWIki installation?

给你一囗甜甜゛ 提交于 2019-12-12 04:56:42

问题


I would like a tool in the sidebar's "Tools" section that takes readers to Special:PrefixIndex/FULLPAGENAME where FULLPAGENAME is replaced with the current page's full name. For example, say I was on the page Module:Citation/CS1 then I would like a tool in the sidebar called Subpages that takes me to Special:PrefixIndex/Module:Citation/CS1. I have seen (the mediawiki sidebar manual) and I added:

function CustomizeModificationsOfSidebar() {
    // Adds PrefixIndex
    var page = mw.config.get( 'wgPageName' );
    ModifySidebar( 'add', 'toolbox', 'Subpages', "http://127.0.0.1/mediawiki/index.php/Special:PrefixIndex/"'page' );
}

jQuery( CustomizeModificationsOfSidebar );

to the page MediaWiki:Common.js. This gave the JavaScript error: Error: Expected ')' and instead saw 'page'. that prevented me from saving the page.


回答1:


Your script is missing a comma, it should be

    ModifySidebar( 'add', 'toolbox', 'Subpages', 'http://127.0.0.1/mediawiki/index.php/Special:PrefixIndex/', 'page' );

Of course, you will have to add the actual ModifySidebar function to.

Alternative approach: Though not recommended in the manual, you can actually use magic words, such as {{FULLPAGENAME}} in MediaWiki:Sidebar, so adding something like this should work:

*Special:PrefixIndex/{{FULLPAGENAME}}|subpages

You might run in to caching troubles, though. Make sure $wgEnableSidebarCache is off in LocalSettings.php (it is by default)

Edit: The comment from Tgr below is also very relevant: This will have performance implications



来源:https://stackoverflow.com/questions/28677871/how-do-i-add-specialprefixindex-fullpagename-to-the-toolbox-in-my-local-mediawi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!