Extension:UniversalSuggester

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
UniversalSuggester
Release status: stable
UniversalSuggester-1.0.png
Implementation Page action, Search, Ajax
Description Adds an extra icon to the edit form bar which simplifies the insertion of markup for page (and sections) links, categories, templates, images and media files. The user starts typing in the input box, the database is queried in the background and a list of matches is returned. The main difference to other link/category/... suggesters is the possibility to easily switch between different suggesters. Therefore only this extension is necessary to query multiple types of MediaWiki document types.
Author(s) Thomas Klein (Cagey83talk)
Latest version 1.01 (2011-12-12)
MediaWiki >= 1.13.0
License GNU GPL, MIT-LICENSE
Download
Hooks used
AlternateEdit
Translate the UniversalSuggester extension if it is available at translatewiki.net
Check usage and version matrix.

The extension Universal Suggester adds an extra icon to the edit form bar which simplifies the insertion of markup for page (and sections) links, categories, templates, images and media files. The user starts typing in the UniversalSuggester input field, the database is queried in the background and a list of matches is returned. The main difference to other link/category/... suggesters is the possibility to easily switch between different suggesters. Therefore only this extension is necessary to query multiple types of MediaWiki documents.

Requirements[edit]

This extension requires at least MediaWiki 1.13.0 and currently only works with the standard MediaWiki editor (the one with the blue button row, without any complex functionality).

Usage[edit]

To activate the suggester either click on the suggester icon (magnifying glass) in the edit toolbar or press Escape (Ctrl + Command also possible on a Mac). By default the link suggester is activated. This is also highlighted by the white background of the input field.

Switching between suggesters[edit]

To switch between suggesters, input a colon (:) followed by

  • a (semantic attributes - if the extension Semantic MediaWiki is installed)
  • c (categories)
  • i (images)
  • f (files)
  • l (links)
  • r (transclusions)
  • t (templates)
  • u (users)

The input field will change its background color to mark the currently activated suggester.

Getting results[edit]

By typing a few letters a list of suggestions shows up. Note: It doesn't matter if the typed text appears at the beginning of a document name or in the middle of it. There's also no case sensitivity. The user can select a result by either clicking on it or move to the selection with the arrow keys and hit the Enter key. He might also just complete his current input with one of the suggestions by moving to it with the arrow keys and hit the Tab key. This way the selection is not directly inserted into the article field. This is useful if the user wants to use extra options as described in the following section.

Using extra options on completed terms[edit]

The suggesters Link, Template and Category offer the possibility to use the #-Char at the end of a completed entry to get specific results from that entry.

An example on that: By using the Link-Suggester the page name SecretOfLife was found and the term is placed in the UniversalSuggester input field. If the user adds the #-Char (having now SecretOfLife#) a new type of suggestions is displayed: the sections of that page which are also selectable and insertable.

The Category-Suggester provides a list of super- and sub-categories and the Template-Suggester a list of all possible params for this template.

For the Category- and Link-Suggester it is also possible to use the #-Char in an empty input field, so that the current page is used as the basis for results. E.g. showing the page sections or the page categories.

Setup[edit]

Go to the method initUS_RequestManager in UniversalSuggester.php and modify the variables $a_suggesters (suggesters in use) and $a_defaultNS (namespaces to check for queries) to fit your needs.

Download instructions[edit]

Please download the extension from SVN or unzip the zip place the files into the extensions folder: $IP/extensions/UniversalSuggester/. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation[edit]

To install this extension, add the following to LocalSettings.php:

require_once("$IP/extensions/UniversalSuggester/UniversalSuggester.php");

Credits[edit]

This extension uses the fabulous jquery library (v1.4.2). Additionally a slightly modified version of the jQuery plugin Autocomplete 1.0.2 by Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer is used.

Also many thanks to the Twoonix Software GmbH for financial support and critical feedback which helped me a lot to finally make the code public.

See also[edit]