On the Vector skin I would like to hide the Toolbox for Anonymous users. How can I do that? Also is there any way to decide which links appear in the Toolbox as for exmaple I don't need the print link to show.
Topic on Project:Support desk/Flow
Thanks but that doesn't stop the Toolbox links appearing in the source code. Those links are hurtful to Search Engine Optimization. I would like to completely remove the Toolbox for users not logged in.
Hack the skin if hiding via CSS is not enough.
Any idea how? I found a tip on how to to that for the Monobook skin but that method doesn't work for Vector.
skins/Vector.php: I guess it's added via
private function renderPortals( $portals ) { ... if ( !isset( $portals['TOOLBOX'] ) ) { $portals['TOOLBOX'] = true; }
Try
private function renderPortals( $portals ) { global $wgUser; ... if ( !isset( $portals['TOOLBOX'] ) && $wgUser->isAllowed('move') ) { $portals['TOOLBOX'] = true; }
Adjust 'move' to the userright which loggedin users are allowed to and anons not.
Hi, my code doesn't look the same as that so I wasn't sure what to do. This is what I have in that file by default:
private function renderPortals( $portals ) { // Force the rendering of the following portals if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true; if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true; // Render portals foreach ( $portals as $name => $content ) { echo "\n\n"; switch( $name ) { case 'SEARCH': break; case 'TOOLBOX': ?>
Could you please tell me what I should use instead of the above.
I would not check, if the user is allowed to move a page. Instead I would check for the user being logged in. You can get that information by setting global $wgUser;. Then $wgUser->isLoggedIn() will return TRUE if the user is logged in, otherwise FALSE.
The 'move' userrright was just an example. Some time ago a dev told me that checking userrights is better than for isLoggedIn.
^^Or was it instead of checking the usergroup?
Hi, I still don't know what I'm supposed to do to hide the Toolbox from anonymous users! I've got MediaWiki 1.16.5
This is what I have in that file by default:
private function renderPortals( $portals ) { // Force the rendering of the following portals if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true; if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true; // Render portals foreach ( $portals as $name => $content ) { echo "\n\n"; switch( $name ) { case 'SEARCH': break; case 'TOOLBOX': ?>
Could you please tell me what I should use instead of the above.
Replace
private function renderPortals( $portals ) { // Force the rendering of the following portals if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true; if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
with:
private function renderPortals( $portals ) { // Force the rendering of the following portals global $wgUser; if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true; if ( !isset( $portals['TOOLBOX'] ) && $wgUser->isLoggedIn() ) $portals['TOOLBOX'] = true;
that code doesn't work for me :f id really like to get this fixed, please help me xD
Small alternative solution, in case the one above doesn't work for you:
Change
private function renderPortals( $portals ) { // Force the rendering of the following portals if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
to
private function renderPortals( $portals ) { // Force the rendering of the following portals global $wgUser; if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
then change
case 'TOOLBOX': $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
to
case 'TOOLBOX': if ( $wgUser->isLoggedIn() ) { $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' ); }
This checks the user login state even if the $portals array already has TOOLBOX defined. Best of luck!
I have MediaWiki 1.16.5. At one point the 1st solution you suggested worked. However on a new installation neither method is working for me. This is how my code looks by default:
private function renderPortals( $portals ) { // Force the rendering of the following portals if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true; if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true; if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
Hacking the MW source is bad. Don't do it!
Instead check if there is a hook which allows modifying the toolbox.
Apart from that I still do not understand why these links should be bad for SEO.
This worked perfectly. I am using Media Wiki more of as a Knowledge base than as a Community Wiki, SEO really doesn't concern me here. I basically want to lock down the Wiki for reading purposes only and there are certain things they do not need to have access to as a reader.
Solution worked:
MarkTraceur (talk)18:57, 1 June 2012
thank you sir.
This works like a charm!!
Thanks a lot!
David
Very awesome! Thanks!
Works! Thank you!