FANDOM


CatNav is a tool for performing an advanced category member listing. It is very similar to the "Category Exhibition" wiki feature, however, it allows you to list pages from multiple categories, as well as specifying categories from which you would not like to list pages.

If you're only interested in a plain list of category members, you might want to check ListPages.

Usage

When installed, a "CatNav" link will appear in the bottom wiki bar. Clicking it would lead you to Special:CatNav, where the feature is found.

CatNav's main component consists of 2 textareas, each is a whitespace-separated list of category names:

  • An "Include" textarea: list here categories from which you'd like to collect pages for the navigation. A page will only be listed if it contains each one of the specified categories. You must specify at least 1 category
  • An "Exclude" textarea: if you prefer not to list pages from certain categories, you can list them here. This textarea is optiona, and you can leave it blank

When you're done, click the "generate" button. If results are found, they will be listed below CatNav's form, with each page represented by a square thumbnail with a title. If there are too many results, they would be divided into subpages.

In addition, there are some extra options:

  • A "favorites" menu above the textareas lets you add frequently-used categories to your favorites. Whenever you enter CatNav in that specific wiki, you favorite categories would be loaded. Left-clicking a category adds it to the Include textarea, and right-clicking it adds it to the Exclude textarea. You can add new favorites and delete items from your favorites.
  • Selecting the number of rows each navigation subpage has (the width is determined by your screen size)
  • The option to list only mainspace pages, or pages from all namespaces (default is articles)
  • Sorting options

Installation

In order to install the feature, add the following content to your personal wikia.js in your wiki (or to your global.js, for FANDOM-wide installation):

importArticles({
	type: "script",
	articles: [
		"u:dev:MediaWiki:CatNav/code.js"
	]
});

Settings

The script always defines a window.CatNav object, with an init method for re-initializing its interface at any given time. You can use it as a function callback, or call CatNav.init at any given moment.

In case the wiki on which you store your favorite categories imports/exports (more info on the global favorites section) is not the Community Central, you can define that in the following manner:

window.CatNav = window.CatNav || {};
window.CatNav.storage = [wikiUrl, scriptPath];

Where:

  • wikiUrl is the full wiki url (e.g. "http://community.wikia.com")
  • scriptPath is the url path to scripts on that wiki (empty string in the case of FANDOM). You can check it with wgScriptPath

Note that CatNav's functionality relies on FANDOM's API, so it will currently not work with non-FANDOM wikis (e.g. WikiMedia wikis, such as Wikipedia and Commons)

Events

You can use custom DOM events to know whenever something happens in CatNav's page. Each event is meant to be triggered by a specific element (using addEventListener or jQuery's .on(), for example). The available events are the following:

Event Target When fired
catnavready document.body When CatNav's interface fully loads
catnavgenerated #catnav Whenever CatNav finishes generating content
catnavpageload #catnav Whenever the user goes to a certain navigation page. If triggered at the same time as catnavgenerated, it will have an additional property of uponGeneration set to true. This can be used if you want catnavpageload to have a different behavior when the script auto-opens the first page after generating content

Global favorites

You can also set a list of favorite categories through the Community Central, through Special:MyPage/catnav.css. Pressing the "import" button would import all favorite categories associated with the current wiki to the local storage in your device (but for changing the global settings, you'd have to edit the global page).

Note that if you already have favorite categories in a given wiki and then press the "import" button, it would not delete favorite categories that do not appear in your global settings for the given wiki, but will just add categories that weren't favorite beforehand.

The syntax is the following:

  a line that starts with space(s) is a comment. you can also leave a line empty

  to declare favorite categores first declare the wiki that they belong to
  to do that, start a line with a '@', followed by the wiki's subdomain
  (use the '<lang>.' prefix if needed)
@clubpenguin
  any category below this line will be from [[w:c:clubpenguin]]
  to declare a category, start a line with a '#'
#Clothing
  the upper line is related to [[w:c:clubpenguin:Category:Clothing]]
#Puffles
#Parties
#Characters/Penguin Band
  ^ you can also use subcategories


  to declare categories for another wiki, re-declare the subdomain. e.g., the spanish Runescape wiki:
@es.runescape
#Armaduras Híbridas‏

Just note:

  • You can declare the same wiki twice, but it's advisable to save all the categories for each wiki together, for an easier category managing.
  • Make sure not to list categories without declaring their associated wikis first.
  • Make sure that the declared wiki's subdomain is valid. Invalid URL characters will result in an error, but merely invalid wiki subdomains may silently get through.
  • Comments can be written by starting the line with any character other than "@" or "#", but please only use spaces as comment line starters, to reserve other characters for possible future updates. Using other characters for comments could create an unexpected behavior in the future.

Credits and special thanks

Versions

  • May 26, 2017- fixed crash that occures if any of the pages in the currently-viewed catnav page contains commas in its title.
  • November 19, 2016- giving a contrast to the results counter, and adding the catnavready and catnavgenerated events.
  • November 19, 2016- adding results counter and the catnavpageload event.
  • October 28, 2016- adding sorting by article comments.
  • October 15, 2016- solving issue with global imports.
  • October 10, 2016- providing global CatNav object. Making script path wiki-specific.
  • October 8, 2016- syntax fixes, fixing sorting issues with sorting by popularity, and extra updates for the export interface.
  • October 7, 2016- added sorting by popularity (uses standard Category Exhibition order, due to limitations of the current popular pages API available in FANDOM and MediaWiki) and the ability to get the exported syntax for your current wiki. Added monobook selectors and added support for wikis with a different "Special:" prefix.
  • September 18, 2016- providing global favorites importing to the current wiki in the current device. Some small CSS changes.
  • September 3, 2016- adding favorite categories and sorting options. Also, now adding empty lines no longer returns an error. Minor changes in the interface and some other code tweaks.
  • September 9, 2015- script improvements and official release in the Dev wiki.
  • March 17, 2015- prototype release in the Club Penguin Wiki.

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.