Tab Removal

From mw.mh370.wiki
Jump to navigation Jump to search


A Guide to Using MediaWiki in a Hosted Environment

An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.


On the mh370wiki.net website I wanted no Tabs. I wanted the page head to be uncluttered. And I did not want to open discussion pages (Talk) or allow the page source to be viewed. I just wanted it to look clean and simple.

Tab removal was achieved by adding the following to Common.css.

#ca-nstab-main { display:none !important; }  /* Page tab */
#ca-talk { display: none !important; }       /* Discussion Tab */
#ca-history { display: none !important;}     /* View History / History Tab */
#ca-viewsource { display: none !important; } /* Users without Edit permission could still view the page source */
#ca-view { display:none!important; }         /* Read Tab (Vector Skin) */

The Edit tab is available to a logged-in user. And 'More' opens the dropdown menu for Delete, Move and Protect. But these are not visible to the anonymous users.

ca-nstab

In the Main namespace the first Tab is labelled Page.

Page Tab

The label can be changed - see Snippets/Main Page tab. In Wikipedia the 'Page' Tab is labelled 'Article'.

Also, in Wikipedia, a mouse-over the Article Tab reveals a message 'View the content page [alt-shift-c]'. This keyboard shortcut is supposed to make it easy for users to quickly switch between the Content and other views of the page, like Discussion (or talk). Wouldn't it be simpler to just click on the Tab? But in the background is a set of Access Keys with functionality modelled on the HTML accesskey attribute. Browsers typically use Alt + Accesskey, or Alt +Shift + Accesskey. In MediaWiki the Accesskey can be defined by creating a page in the MediaWiki Namespace, for example:-

MediaWiki:Accesskey-ca-nstab-main

Add a single letter in this page, a c perhaps, and that will become the keyboard shortcut (with alt + shift) to switch the page view to the article or content.

The components of the page name are Accesskey, then the prefix ca-nstab, then main. This defines the accesskey for the Main namespace only.

However, a more common requirement may be to remove the 'Page' tab completely. This is simple by adding the line   #ca-nstab-main { display:none !important; }   to MediaWiki:Common.css.

So, to remove the Tab which relates to a namespace, and using the format of the working example   #ca-nstab-main { display:none !important; }   it should be possible to remove the Tab associated with other namespaces by adding a similar line to MediaWiki:Common.css. For example:-

#ca-nstab-namespace_name { display:none !important; }

This website has a public namespace called Snippets. Here is the associated namespace tab:-

Namespace Tab for Snippets namespace

Now this line has been added to MediaWiki:Common.css#ca-nstab-snippets { display:none !important; }   And here is the result, with a page name included to show the namespace prefix Snippets: And there is no associated namespace tab:-

Page in Snippets namespace without a Tab

Can the namespace be identified by Number instead of Name?

The Snippets namespace was defined like this - define("NS_SNIPPETS", 3400);

The Discussion (Talk) tab can be removed by specifying the namespace by number, for example this works:-

body.ns-3400 #ca-talk { display:none !important; }

But I couldn't remove the tab labelled Snippets by using similar CSS.


Tab Removal in the mh370wiki.net Website

Namespace Tabs

There are several namespaces which hold public content. Two namespaces had unfriendly names:-

  • FI_2015
  • SIR_2018

The Namespace name appeared in a Tab but hadn't bothered me until now.

Namespace FI_2015 in a Tab

To make the displayed names more friendly I changed the name of each namespace to a descriptive title and retained the original name as the alias. This is quite safe - the namespace Number is critical and changing it effectively causes all the content to be lost and a new empty namespace to be created. So don't do that!

The new namespace names are:

  • Factual Information (2015) with an alias FI_2015
  • Safety Investigation Report (2018) with an alias SIR_2018

But now the page head looks like this:-

Longer Namespace name in Tab

And

Longer Namespace name in Tab

Removing the Tab with the Namesace Name

The page source, shown by Firefox Web developer Tools, contains the various classes, including the id ca-nstab-safety_investigation_report_(2018). A similar id is generated for the Factual Information (2015).

Page source showing Tab in Left Navigation Tab

In the previous example, the CSS#ca-nstab-snippets { display:none !important; }   was effective in removing the tab labelled Snippets. So, logically, one would think that this line in MediaWiki:Common.css would be effective too:-

#ca-nstab-safety_investigation_report_(2018) { display: none !important; }

But it isn't. Doesn't work. The brackets ( ) are the problem

I re-named each namespace:-

  • Factual Information 2015 with an alias FI_2015
  • Safety Investigation Report 2018 with an alias SIR_2018

The associated tabs have been removed with these lines added to MediaWiki.Common.css:-

#ca-nstab-factual_information_2015 { display: none !important; }

#ca-nstab-safety_investigation_report_2018 { display: none !important; }

Success!


A Workaround

Here is a workaround. It worked, but there had to be a better way, and I think I found it, as above.

The Tab containing the Namespace name has a white background. I figure that one way to check if you have identified a target item is to change its colour.

Here is the CSS creating the white background:-

Identifying the class by its white background

I added this to Common.css.vector-menu-tabs-legacy .selected { background:green; }   with this result:-

Namespace tab with green background

Bold colours prove the CSS is functional!

So now I have added this line to Common.css.vector-menu-tabs-legacy .selected { display: none !important; }   with this result:-

Page Head with no Tab for namespace name

The applied CSS is captured here:-

White namespace tab not displayed in page head

As you can see, the tab still has a white background, but the display:none has finally been effective. It also works for all custom namespaces.


Next Steps

  1. Apply similar CSS to remove tabs associated with other namespaces.
  2. Use the magic word DISPLAYTITLE to make some abbreviated page names (like TOC) more friendly or meaningful. This is only possible after solving problems with getting DISPLAYTITLE to work properly.

Links

Manual:Removing tabs
https://www.mediawiki.org/wiki/Manual:Removing_tabs
Hide page tabs
https://www.mediawiki.org/wiki/User:Subfader/Hide_page_tabs
How to remove the top navigation page tabs in MediaWiki
https://www.hostknox.com/knowledgebase/674/How-to-remove-the-top-navigation-page-tabs-in-MediaWiki.html