Extension:ConditionalMenus

ConditionalMenus extension allows to show or not show certain parts of a page, depending on what the page name is and what categories are in the ancestry of the page. It is useful in pages that are usually included, to allow for dynamic menus or headers.

The extension parses the following example:

ConditionalMenus Extension Leet Category Abraham Category 3

Link1 Link2 Link3

What does it do?
In our example: If the page's name is "ConditionalMenus Extension" then anything inside the content tag is shown. If the page is of category "Leet Category" then anything inside the content tag is shown If the page is of category "Abraham Category" or is of a category that is of category "Abraham Category" (and so on...) then anything inside the content tag is shown In any other scenario nothing is parsed

Conditionally opened submenu
For example, you have navigation like:

Introduction Series information Category:Characters Guide Category:Episode List Goofs

And you want to display the list of characters but ONLY in the character pages (and maybe in an intro page), then you'd use:

Introduction Series information Category:Characters Guide Characters Guide Joe Characters Guide 2 Joe Mac Peter Category:Episode List Goofs

this would show the "Joe, Mac and Peter" links to the user ONLY if he is inside the "Characters Guide" page, or if he is inside the Joe page, or if he is inside any page that belongs to the "characters guide" category

This way if the user is browsing the "Introduction" pages he sees the small menu, and as soon as he enters to the "Characters Guide" category page he also sees the list of characters

Different header images for different categories, one default header
Suppose the pages of your wiki are divided into three main categories, say "Work", "Family", and "Nonsense". Your Skin includes a header with an image at the top of each page, and you want this image to be different depending on the category of the current site. Of course, there are also pages that are not part of your trinity, for example project pages, special pages, and any page that hasn't been categorized yet. You want to give these pages a default header image.

You would write your header page (the one that is included at the top) as follows:

HeaderImage Work HeaderImage Family HeaderImage Nonsense HeaderImage

The last submenu is the else-case: It looks up whether the content of any submenus of the HeaderImage group have already been displayed and if not, displays its own content.

How to use it

 * 1) Copy everything inside "Code" below into a file called "navigation.php" and put it under your "extensions" folder
 * 2) In LocalSettings.php, add: include("extensions/navigation.php");
 * 3) Done! :)