Fandom

Wikia Developers Wiki

AddNavMenuItems

888pages on
this wiki
Add New Page
Talk5 Share

It is frustrating that Wikia only allows Admins to add four top level menu items to their "Expanded Wiki Navigation". This script will allow you to add additional top level menus, with working sub-menus and drop-down menus.

Version 2.0 Allows menus to be added based on the content of the current page. For example, on the Elder Scrolls Wiki when viewing a morrowind page, a new menu will be added for morrowind specific content. This is especially helpful for wikis that cover more than one subject (like video games or movies with sequels) but do not have enough space to in their navigation for them all.

Warning! Do not add too many items to your menu! If you do it will either overlap the "contribute" bar to the right of the menu, or will drop below/behind the menu. You are not allowed to cover up or change wikia's layout in any negative way.

Version 2.0

Installation

The following scripts must be copied to your common.js DIRECTLY. It cannot be loaded in as a separate file. Otherwise it fires too late and it will not work on google chrome.

Part 1

These are the basic functions to be used. Copy these over and proceed to part 2.

Part 2

Below is the configuration used by the Elder Scrolls Wiki to dynamically add menus based a page's categories.

  • getPageType determins the current page type by its categories, and returns an array of all possabilities
  • addMenusToWikiNav calls getPageType and calls the appropriate add menu function. This function will add up to 3 menus (otherwise the nav will overflow). If there are three menus to add, it moves the community menu to the "on the wiki" menu to make space for the new menu item.

I could go into more detail explaining this system, but it should be self-explanitory for any experienced programmer. If you are having trouble getting this working on your wiki either contact another admin or contace me, jgjake2. I am more than willing to help anyone get this working on their wiki.


function fixElderScrollsNavigation(){
	if(getUrlVars()["action"] == "edit") return;
	var wikiNavUl = getWikiNavUl();
	if(wikiNavUl == null) return;
	var addMenus = getPageType();
	addMenusToWikiNav(addMenus, wikiNavUl);
}
addOnloadHook(fixElderScrollsNavigation);
 
function addMenusToWikiNav(menuList, wikiNavUl){
	if(!menuList) return;
	var maxMenus = 3;
	var count = 0;
	if(menuList.length > 2) fixCommunityMenu(wikiNavUl);
	for (x in menuList){
		if(count >= maxMenus) {
			return;
		}
		switch(menuList[x]){
			case 'Arena':
				addArenaMenu(wikiNavUl);
				count++;
				break;
			case 'Daggerfall':
				addDaggerfallMenu(wikiNavUl);
				count++;
				break;
			case 'Morrowind':
				addMorrowindMenu(wikiNavUl);
				count++;
				break;
			case 'Oblivion':
				addOblivionMenu(wikiNavUl);
				count++;
				break;
		}
	}
}
 
function getPageType(){
	document.body.getElementsByTagName("nav")[1].style.width="630px";
	var addMenus = [];
    var categoryDiv = document.getElementById('mw-normal-catlinks');
    if(categoryDiv){
        var categoryDiv_Links = categoryDiv.getElementsByTagName("a");
        for (x in categoryDiv_Links){
			switch(categoryDiv_Links[x].title){
				case 'Category:Arena: Characters':
				case 'Category:Arena: Classes':
				case 'Category:Arena: Creatures':
				case 'Category:Arena: Locations':
				case 'Category:Arena: Quests':
				case 'Category:Artifacts in Arena':
				case 'Category:Factions in Arena':
				case 'Category:Arena':
					//alert('Arena!');
					if(elementExists(addMenus, 'Arena') == false) addMenus.push('Arena');
					break;
				case 'Category:Daggerfall: Books':
				case 'Category:Daggerfall: Characters':
				case 'Category:Daggerfall: Creatures':
				case 'Category:Daggerfall: Factions':
				case 'Category:Daggerfall: Locations':
				case 'Category:Daggerfall: Males':
				case 'Category:Factions in Daggerfall':
				case 'Category:Daggerfall':
					//alert('Daggerfall!');
					if(elementExists(addMenus, 'Daggerfall') == false) addMenus.push('Daggerfall');
					break;
				case 'Category:Factions in Morrowind':
				case 'Category:Morrowind: Ashlander':
				case 'Category:Morrowind: Books':
				case 'Category:Morrowind: Characters':
				case 'Category:Morrowind: Creatures':
				case 'Category:Morrowind: Dunmer':
				case 'Category:Morrowind: Factions':
				case 'Category:Morrowind: Imperials':
				case 'Category:Morrowind: Ingredients':
				case 'Category:Morrowind: Items':
				case 'Category:Morrowind: Locations':
				case 'Category:Morrowind: Potions':
				case 'Category:Morrowind: Skill books':
				case 'Category:Morrowind: Skills':
				case 'Category:Morrowind: Thieves Guild Quests':
				case 'Category:Morrowind: Thieves Guild members':
				case 'Category:Morrowind':
					//alert('Morrowind!');
					if(elementExists(addMenus, 'Morrowind') == false) addMenus.push('Morrowind');
					break;
				case 'Category:Artifacts in Oblivion':
				case 'Category:Oblivion: Armor':
				case 'Category:Oblivion: Books':
				case 'Category:Oblivion: Characters':
				case 'Category:Oblivion: Classes':
				case 'Category:Oblivion: Creatures':
				case 'Category:Oblivion: Factions':
				case 'Category:Oblivion: Imperials':
				case 'Category:Oblivion: Ingredients':
				case 'Category:Oblivion: Items':
				case 'Category:Oblivion: Locations':
				case 'Category:Oblivion: Quests':
				case 'Category:Oblivion: Skills':
				case 'Category:Oblivion: Spells':
				case 'Category:Oblivion: Thieves Guild members':
				case 'Category:Oblivion: Weapons':
				case 'Category:Oblivion':
					//alert('Oblivion!');
					if(elementExists(addMenus, 'Oblivion') == false) addMenus.push('Oblivion');
					break;
			}
        }
		return addMenus;
    }
}
 
function addArenaMenu(wikiNavUl){
	var menu0 = ['/wiki/The_Elder_Scrolls:_Arena', 'Arena'];
	var menu1 = [
		['/wiki/Quests_in_Arena', 'Quests'],
		['/wiki/Main_Quest_(Arena)', 'Main Quest'],
		['/wiki/Side_Quests_(Arena)', 'Side Quests']
	];
	var menu2 = [
		['/wiki/The_Elder_Scrolls:_Arena#Gameplay', 'World'],
		['/wiki/Map_(Arena)', 'Map'],
		['/wiki/Creatures_in_Arena', 'Creatures'],
		['/wiki/Location_(Arena)', 'Locations'],
                ['/wiki/Races_(Arena)', 'Races'],
		['/wiki/Attributes', 'Attributes'],
		['/wiki/Magic_(Arena)', 'Magic']
	];
	var menu3 = [
		['/wiki/Items (Arena)', 'Items'],
		['/wiki/Artifacts_(Arena)', 'Artifacts'],
		['/wiki/Spellbooks_(Arena)', 'Spellbooks']
	];
	var menu4 = [
		['/wiki/Damage_(Arena)', 'Damage'],
		['/wiki/Disease_(Arena)', 'Diseases'],
		['/wiki/Curses_(Arena)', 'Curses'],
		['/wiki/Potions_(Arena)', 'Potions']
	];
	var menuItemsArray = [menu1, menu2, menu3, menu4];
	addArrayToWikiaNavUl_TopLevel(menu0, menuItemsArray, wikiNavUl);
}
 
function addDaggerfallMenu(wikiNavUl){
	var menu0 = ['/wiki/The_Elder_Scrolls_II:_Daggerfall', 'Daggerfall'];
	var menu1 = [
		['/wiki/Quests_(Daggerfall)', 'Quests'],
		['/wiki/Main_Quest_(Daggerfall)', 'Main Quest'],
		['/wiki/Dark_Brotherhood_(Daggerfall)#Quests', 'Dark Brotherhood'],
		['/wiki/Fighters_Guild_(Daggerfall)', 'Fighters Guild'],
		['/wiki/Knight_Orders', 'Knight Orders']
	];
	var menu2 = [
		['/wiki/The_Elder_Scrolls_II:_Daggerfall#Game_world', 'Gameplay'],
		['/wiki/Attributes', 'Attributes'],
		['/wiki/Race', 'Races'],
		['/wiki/Skills_(Daggerfall)', 'Skills'],
		['/wiki/Category:Daggerfall:_Locations', 'Locations'],
		['/wiki/Factions_(Daggerfall)', 'Factions'],
		['/wiki/Reputation_(Daggerfall)', 'Reputation'],
		['/wiki/Category:Daggerfall:_Creatures', 'Creatures']
	];
	var menu3 = [
		['/wiki/Items_(Daggerfall)', 'Items'],
		['/wiki/Artifact_(Daggerfall)', 'Artifacts'],
		['/wiki/Category:Daggerfall:_Books', 'Books']
	];
	var menu4 = [
		['/wiki/The_Elder_Scrolls_II:_Daggerfall#Game_world', 'Damage'],
		['/wiki/Combat_(Daggerfall)', 'Combat'],
		['/wiki/Disease_(Daggerfall)', 'Disease'],
		['/wiki/Lycanthropy_(Daggerfall)', 'Lycanthropy'],
		['/wiki/Vampirism_(Daggerfall)', 'Vampirism'],
		['/wiki/Potions_(Daggerfall)', 'Potions']
	];
	var menuItemsArray = [menu1, menu2, menu3, menu4];
	addArrayToWikiaNavUl_TopLevel(menu0, menuItemsArray, wikiNavUl);
}
 
function addMorrowindMenu(wikiNavUl){
	var menu0 = ['/wiki/The_Elder_Scrolls_III:_Morrowind', 'Morrowind'];
	var menu1 = [
		['/wiki/Quests_in_Morrowind', 'Quests'],
		['/wiki/Main_Quest_(Morrowind)', 'Main Quest'],
		['/wiki/Fighters_Guild_(Morrowind)#Balmora_Missions', 'Fighters Guild'],
		['/wiki/Mages_Guild_(Morrowind)#Quests', 'Mages Guild'],
		['/wiki/Thieves_Guild_(Morrowind)#Thieves_Guild_Quests', 'Thieves Guild']
	];
	var menu2 = [
		['/wiki/The_Elder_Scrolls_III:_Morrowind#Gameplay', 'Gameplay'],
		['/wiki/Attributes', 'Attributes'],
		['/wiki/Race', 'Races'],
		['/wiki/Birthsigns_(Morrowind)', 'Birthsigns'],
		['/wiki/Classes_(Morrowind)', 'Classes'],
		['/wiki/Skills_(Morrowind)', 'Skills'],
		['/wiki/Category:Morrowind:_Locations', 'Locations'],
		['/wiki/Category:Morrowind:_Creatures', 'Creatures']
	];
	var menu3 = [
		['/wiki/Category:Morrowind:_Items', 'Items'],
		['/wiki/Weapons_(Morrowind)', 'Weapons'],
		['/wiki/Artifacts_(Morrowind)', 'Artifacts'],
		['/wiki/Category:Morrowind:_Books', 'Books']
	];
	var menu4 = [
		['/wiki/The_Elder_Scrolls_III:_Morrowind', 'Expansions'],
		['/wiki/The_Elder_Scrolls_III%3A_Tribunal', 'Tribunal'],
		['/wiki/The_Elder_Scrolls_III:_Bloodmoon', 'Bloodmoon']
	];
	var menuItemsArray = [menu1, menu2, menu3, menu4];
	addArrayToWikiaNavUl_TopLevel(menu0, menuItemsArray, wikiNavUl);
}
 
function addOblivionMenu(wikiNavUl){
	var menu0 = ['/wiki/The_Elder_Scrolls_IV:_Oblivion', 'Oblivion'];
	var menu1 = [
		['/wiki/Category:Oblivion:_Quests', 'Quests'],
		['/wiki/Main_Quest_(Oblivion)', 'Main Quest'],
		['/wiki/Side_Quests_(Oblivion)', 'Side Quests'],
		['/wiki/Dark_Brotherhood_(Oblivion)#Quests', 'Dark Brotherhood'],
		['/wiki/Fighters_Guild_(Oblivion)#Quests', 'Fighters Guild'],
		['/wiki/Mages_Guild_(Oblivion)#Quests', 'Mages Guild'],
		['/wiki/Thieves_Guild_(Oblivion)#Quests', 'Thieves Guild']
	];
	var menu2 = [
		['/wiki/The_Elder_Scrolls_IV:_Oblivion#Gameplay_Information', 'Gameplay'],
		['/wiki/Attributes_(Oblivion)', 'Attributes'],
		['/wiki/Race', 'Races'],
		['/wiki/Birthsigns_(Oblivion)', 'Birthsigns'],
		['/wiki/Classes_(Oblivion)', 'Classes'],
		['/wiki/Skills_(Oblivion)', 'Skills'],
		['/wiki/Category:Oblivion:_Locations', 'Locations'],
		['/wiki/Category:Oblivion:_Creatures', 'Creatures']
	];
	var menu3 = [
		['/wiki/Category:Oblivion:_Items', 'Items'],
		['/wiki/Category:Artifacts_in_Oblivion', 'Artifacts'],
		['/wiki/Category:Oblivion:_Armor', 'Armor'],
		['/wiki/Category:Oblivion:_Weapons', 'Weapons'],
		['/wiki/Category:Oblivion:_Books', 'Books'],
		['/wiki/Category:Oblivion:_Ingredients', 'Ingredients']
	];
	var menu4 = [
		['/wiki/The_Elder_Scrolls_IV:_Oblivion', 'Expansions'],
		['/wiki/The_Elder_Scrolls_IV%3A_Shivering_Isles', 'Shivering Isles'],
		['/wiki/Knights_of_the_Nine', 'Knights of the Nine'],
		['/wiki/Official_Plug-ins', 'Plug-ins']
	];
	var menuItemsArray = [menu1, menu2, menu3, menu4];
	addArrayToWikiaNavUl_TopLevel(menu0, menuItemsArray, wikiNavUl);
}
 
function fixCommunityMenu(wikiNavUl){
	var newCommunityMenu = [
		['/wiki/Elder_Scrolls:Community_Portal', 'Community'],
		['/wiki/The_Elder_Scrolls_Wiki:About', 'About'],
		['/wiki/The_Elder_Scrolls_Wiki:Staff', 'Staff'],
		['/wiki/The_Elder_Scrolls_Wiki:Policies_and_guidelines', 'Policies'],
		['/wiki/IRC', 'Chat with other editors'],
		['/wiki/Forum:Index', 'Forums'],
		['/wiki/Blog:Recent_posts', 'Blogs'],
		['/wiki/News', 'Recent News']
	];
	removeWikiaFirstLevelItem(wikiNavUl, 4);
	addArrayToWikiaNav_SecondLevel(newCommunityMenu, 1);
}

Version 1.0

Example of Proper usage: Dead Island Wiki

Installation

Add this to your wiki's common.js file:

Usage

You add menu items by calling "addArrayToWikiaNav". Documentation can be found above the function.

Example

The following example (which can be found here)is a function that adds: 1 top level menu item, 4 second level menu items. It adds no third level items to the first drop-down menu, 3 to the second drop-down menu, 6 to the third drop-down menu, and 2 to the fourth drop-down menu.

function addPCModsMenu(){
	var menu0 = ['/wiki/GameFiles:Mods_and_Tweaks', 'PC Mods'];
	var menu1 = [
		['/wiki/GameFiles:Mods_and_Tweaks/How_To_Mod_Dead_Island', 'How To Mod Dead Island']
	];
	var menu2 = [
		['/wiki/GameFiles:Mods_and_Tweaks#Character_Mods', 'Character Mods'],
		['/wiki/GameFiles:Mods_and_Tweaks/Carry_Food_Mod', 'Carry Food Mod'],
		['/wiki/GameFiles:Mods_and_Tweaks/Human_Level_Cap_Mod', 'Human Level Cap Mod'],
		['/wiki/GameFiles:Mods_and_Tweaks/Max_Stack_Mod', 'Max Stack Mod']
	];
	var menu3 = [
		['/wiki/GameFiles:Mods_and_Tweaks#Game_Tweaks', 'Game Tweaks'],
		['/wiki/GameFiles:Mods_and_Tweaks/Auto-Equip_Fix_Mod', 'Auto-Equip Fix Mod'],
		['/wiki/GameFiles:Mods_and_Tweaks/Character Jump Mod', 'Character Jump Mod'],
		['/wiki/GameFiles:Mods_and_Tweaks/Enable Chat With Xbox 360 Controller', 'Enable Chat With Xbox 360 Controller'],
		['/wiki/GameFiles:Mods_and_Tweaks/Exploding_Meat_Mod', 'Exploding Meat Mod'],
		['/wiki/GameFiles:Mods_and_Tweaks/Low_Gravity_Mod', 'Low Gravity Mod'],
		['/wiki/GameFiles:Mods_and_Tweaks/Zombie Level Cap Mod', 'Zombie Level Cap Mod']
	];
	var menu4 = [
		['/wiki/GameFiles:Mods_and_Tweaks#HUD_Mods', 'HUD Mods'],
		['/wiki/GameFiles:Mods_and_Tweaks/Stop_Health_%26_Weapon_Fade', 'Stop Health & Weapon Fade'],
		['/wiki/GameFiles:Mods_and_Tweaks/Triple_Monitor_Support_Mod', 'Triple Monitor Support Mod']
	];
	var menuItemsArray = [menu1, menu2, menu3, menu4];
	addArrayToWikiaNav(menu0, menuItemsArray);
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.