User:Subfader/Hide page tabs
Contents |
[edit] Generally
The following needs to be added to your MediaWiki:Common.css or your personal user css.
[edit] No tab on all pages
This hides the [watch] tab on all pages.
#ca-watch { display: none !important; }
[edit] No tab per namespace
This hides the discussion tab for all pages on the Help namespace. Therefore you need to find out which number the desired namespace has. Easiest might be to check the source code of a page and scroll down to the body tag (it's stated in the body class).
For the Help namespace it's the css class "ns-12": <body class="mediawiki ltr ns-12 ns-subject page-Help_Contents skin-monobook">
.
.ns-12 #ca-talk { display: none !important; }
[edit] No tab per page name
This hides the [discussion] tab on certain pages. To find the page title for the css code; check the source code of your desired page and scroll down to the body tag (it's stated in the body class).
For e.g. Help:Contents it's the css class "page-Help_Contents": <body class="mediawiki ltr ns-12 ns-subject page-Help_Contents skin-monobook">
.
.page-Help_Contents #ca-talk { display: none !important; }
Note that your Main Page title may be customized and not be "page-Main_Page".
[edit] By Conditional clauses
This describes how to hide certain tabs for certain user groups or page restrictions. Add the following at the end of the skin's head (e.g. Monobook.php above <div id="globalWrapper">
).
[edit] No tabs for certain pages
This hides the [view source] tab on protected pages.
<!-- No [view source] tab on protected pages --> <?php global $wgTitle; if( $wgTitle->isProtected('edit') ) { ?> <style type="text/css"> #ca-viewsource { display: none !important; } </style> <?php } ?>
[edit] No tabs for certain users
This hides the [view source] tab for anonymous users. Makes sense if you disabled editing for those.
<!-- No [view source] tab for anonymous users --> <?php global $wgUser; if( $wgUser->isAnon() ) { ?> <style type="text/css"> #ca-viewsource { display: none !important; } </style> <?php } ?>
This hides the [view source] tab for users who are not allowed to edit pages. The user right 'edit'
can be adjusted by your needs: Just add the according name from this list.
<!-- No [view source] tab for users who can not edit --> <?php global $wgUser; if( !$wgUser->isAllowed('edit') ) { ?> <style type="text/css"> #ca-viewsource { display: none !important; } </style> <?php } ?>
[edit] In combination
This hides the [view source] tab on protected pages to users who are not allowed to delete pages.
<!-- No [view source] tab on protected pages for users who can not delete --> <?php global $wgTitle, $wgUser; if( $wgTitle->isProtected('edit') && !$wgUser->isAllowed('delete') ) { ?> <style type="text/css"> #ca-viewsource { display: none !important; } </style> <?php } ?>
[edit] Notes
- Hiding a tab by CSS doesn't prevent users from accessing the page nontheless. The page can still be accessed by typing the according parameter to the URL or it may simply be linked by another page like special pages.
- Those tricks do not work if the tab is explicitly forced by an extension or the user's CSS.
- To hide other tabs you need the tab's list ID. To find it mark the tabs > right-click > view source (or whatever it is called in your browser). E.g. for the discussion tab it is id="ca-talk".