User:Subfader/Hide page tabs

This page describes how to hide page tabs. Some of the instructions may not work for your wiki. Use with caution.

Generally edit

The following needs to be added to your MediaWiki:Common.css or your personal user css.

No tab on all pages edit

Code Hides
#ca-nstab-main { display:none!important; } Page tab
#ca-nstab-user { display:none!important; } User page tab (the Page tab on personal user pages)
#ca-talk { display:none!important; } Discussion tab
#ca-view { display:none!important; } Read tab (from the prepackaged skins this tab is available only in the Vector skin)
#ca-edit { display:none!important; } Edit tab
#ca-history { display:none!important; } View history/History tab
#ca-watch { display:none!important; } the Watch tab for adding the page to the watchlist
#ca-unwatch { display:none!important; } the Unwatch tab for removing the page from the watchlist
#ca-delete { display:none!important; } Delete tab (in the Vector skins it's displayed with the More drop-down menu)
#ca-move { display:none!important; } Move tab (in the Vector skin it's part of the More drop-down menu)
#ca-protect { display:none!important; } Protect tab (as the previous two, with the Vector skin it's in the More drop-down menu)
#ca-viewsource { display:none!important; } View source tab; this tab is available for users who belong to user groups that don't have the permission to edit pages. With it the user can view the source text of the page without being able to modify it.

No tab per namespace edit

This hides the discussion tab for all pages on the Help namespace. Therefore you need to find out which number the desired namespace has. The listing is found here: Help:Namespace#List of namespaces. Alternatively, 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; }

No tab per page name edit

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; }

Your Main Page title may be customized and not be "page-Main_Page".

By Conditional clauses edit

This describes how to hide certain tabs for certain user group.

Add the below coding to the end of the skin's head (e.g. Monobook.php above <div id="globalWrapper">).

No tabs for certain pages edit

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 } ?> 

No tabs for certain users edit

This hides the [view source] tab for anonymous users. This makes sense if you have disabled editing for anonymous users.

<!-- 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 } ?>

In combination edit

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: block!important; }
      </style> 
    <?php } ?> 

Notes edit

  • 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.
  • The coding on this page does not work if the tab is explicitly shown by an extension or the user's own CSS.
  • To hide other tabs find the tab's list ID. To find it mark the tabs > right-click > view source (or whatever it is called in your browser). For example the discussion tab it is id="ca-talk".

See also edit

External links edit