问题
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