Handbuch: Interface/Navigationsleiste

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Manual:Interface/Sidebar and the translation is 51% complete.

Other languages:
Deutsch • ‎English • ‎Taqbaylit • ‎español • ‎français • ‎italiano • ‎português • ‎русский • ‎سرائیکی • ‎日本語
Beispiel einer Navigationsleiste

MediaWiki:Navigationsleiste definiert die Navigationsleiste, die Verweise zu den meisten, wichtigen Zielen in der Wiki enthält und den Administratoren der Seite (site) einen Ort bietet, eine bleibende Sammlung von Verweisen einzufügen. Zum Beispiel zeigen die meisten Verweise in der Wiki auf deren Diskussionen in der Gemeinschaft (Community discussion) und einige nützliche Werkzeuge.

In Monobuch und Vector Oberfläche (skin) befindet sich die Navigationsleiste oben links (oben rechts für rechts nach links Sprachen) zusammen mit der Suchleiste und den Werkzeugen. In anderen Oberflächen kann der Platz kann unterschiedlichen Stellen sein. Diese Navigationsleiste wird aber Benutzern von Handys nicht gezeigt.

Anpassung der Navigationsleiste

Um die MediaWiki:Navigationsleiste in einem Wiki anzupassen, muss man sich zuerst als ein Benutzer einloggen, der eine editinterface Erlaubnis hat - für Administratoren ist dies schon vorgegeben. Informationen, eine Erlaubnis für Gruppen oder Benutzer zu erhalten, findet man unter Handbuch:Benutzerrechte.

Dann verwenden Sie einen Verweis zu einer Seite Ihrer Wiki, aber ersetzen Sie den Titel Ihrer Wikiseite (z.B. Hauptseite) in der URL-Adressleiste mit MediaWiki:Navigationsleiste und laden Sie die Seite. Sie sollten nun den aktuellen Inhalt der Navigationsleiste sehen. Es kann sein, dass Sie die Syntax "//IhreDomain/IhrWiki/index.php?title=MediaWiki:Navigationsleiste&action=edit" für lange URL´s verwenden müssen.

Wurde der Inhalt der Navigationsleiste bereits geändert, kann einfach auf den Verweis "Editieren" oder "Quelle editieren" klicken. Ansonsten muss man die Seite erst erstellen, indem man auf "Erstellen" oder "Quelle erstellen" klickt.

Hinweis: Wird eine neue Seite erstellt, dann wird ein vorgegebener Inhalt zur Navigationsleiste im Editor angezeigt. Um erfolgreich eine Seite der MediaWiki:Navigationsleiste zu erstellen, muss dieser Inhalt vor dem Speichern angepasst werden.

Nachfolgend ein Beispielcode für eine Navigationsleiste:

* navigation
** mainpage|mainpage
** Special:RecentChanges|Recent changes
* new heading
** portal-url|portal
** http://www.mediawiki.org|MediaWiki home

Dieses Beispiel führt zu folgender Navigationsleiste:

Beispiel einer Navigationsleiste

Überschriften

The navigation bar can be split into sections, each with a heading of its own. The heading for each section is taken from the first-level list element ("navigation" and "new heading" in the example above).

If this text corresponds to the name of an interface message (an existing page of that title in the MediaWiki namespace), then the text of that page is used as a label; otherwise, the header title is used as-is.

Verweise (links)

Listenelemente der zweiten Ebene sind Verknüpfungen ("mainpage|mainpage" im obigen Beispiel) der Form:

** target|link text
target
The link target can be the name of an interface message (page in the MediaWiki namespace) or wiki page, or an external link. In either case, the link can be internal, interwiki, or external. In some cases (such as links with the "&" character), an interface message is necessary. The link target cannot be made dependent on the interface language set in the preferences.
Algorithm followed:
  1. Get the target text.
  2. If there is an existing or default interface message with that name, use the content of that message instead of the target text.
  3. If the output from the previous step is a valid URL (beginning with http:// or other URL protocol), the link will point to that URL.
  4. Else, it will treat it as the link target of a wikilink (linking to that page name or interwiki).
  5. In case it would end up linking to '-', the whole entry is removed from the sidebar (that's useful for removing an entry on all languages by changing the message holding the link).
Beispiele:
  • "** portal-url|portal" uses the text of MediaWiki:Portal-url (which contains "Project:Community portal").
  • "** Special:RecentChanges|Recent changes" links to Special:RecentChanges, since there is no interface message of that name.
  • "** w:Foo|Some interwiki page" Verweise (links) zu w:Foo aus dem gleichen Grund.
  • "** http://www.mediawiki.org|MediaWiki home" verweist auf http://www.mediawiki.org aus dem gleichen Grund.
link text
The link text can be the name of an interface message (page in the MediaWiki namespace) or plain text.
  • If the link text is the name of an existing or default interface message, the content of that message will be used. MediaWiki will check for localized versions; for example, if the current language is fr (French) and the link text is the interface message "forum", it will check for "forum/fr" before using "forum".
  • Otherwise, the link text is used as the target as-is.
  • Notice that the link text is not optional as in normal wiki links. If the link text is missing, the item is ignored.
Beispiele:
  • ** Homepage|mainpage uses MediaWiki:Mainpage (which contains "MediaWiki").
  • ** Special:Recentchanges|Recent changes uses "Recent changes", since there is no interface message of that name.

Reihenfolge der Elemente

By default, the sidebar consists of elements in this order: navigation, search, toolbox, languages. The order can be changed (in MediaWiki 1.13+) by adding special keywords (SEARCH, TOOLBOX and LANGUAGES) to MediaWiki:Sidebar using the heading syntax. For example, the following code moves the search box to the top of the sidebar:

* SEARCH
* navigation
** mainpage|mainpage
** Special:Recentchanges|Recent changed
* new heading
** portal-url|portal
** http://www.mediawiki.org|MediaWiki home

Tooltips and Accesskey

If you add an item to the sidebar, it will have no tooltip associated. But you can create such a tooltip by simply :[1]

  • create a wiki page named "MediaWiki:Tooltip-n-<id of the item>"
  • and put the tooltip in that page.

Accesskey is also be created:

  • create a wiki page named "MediaWiki:Accesskey-n-<id of the item>"
  • and put the accesskey in that page.

Example:

Übersetzungen

Verwendete Ausdrücke/Texte können durch das Bearbeiten der betreffenen Seiten im MediaWiki Namensraum übersetzt werden.

Beispiel: der Ausdruck, der den Punkt mit Namen "Hauptseite" ersetzt, kommt aus MediaWiki:Mainpage. Um den Text für Benutzer, die das Wiki in Deutsch ansehen, einzusetzen/zu ändern, kann der betreffende Text auf der Seite MediaWiki:Mainpage/de eingetragen werden.

Damit können diese Texte einfach mit dem MediaWiki-Interface übersetzt werden.

"Beachte", dass MediaWiki durch Vorgabe den Inhalt der Navigationsleiste in "der" Sprache nutzt, die der vorgegebenen Sprache Ihres Wikis entspricht. Wenn also Ihre Wiki z.B. französisch als vorgegebene Sprache nutzt, erstellen/bearbeiten Sie MediaWiki:Mainpage/fr, um allen Nutzern, die ihre Spracheinstellung nicht geändert haben und allen anonymen Nutzern eine angepaßte Navigationsleiste anzuzeigen.

For more advanced translation, see Help:Extension:Translate/Unstructured element translation.

Erweiterte Anpassung

The sidebar can be fully customized by implementing JavaScript or Cascading Style Sheets, or by editing the PHP files directly. Before using these methods, note that:

  • JavaScript is fragile: it will not work for users with JavaScript disabled, and scripts frequently fail in different browsers or skins.
  • Editing the PHP files can easily cause unexpected errors, and your changes will be lost in the next update unless you manually change the new files.

Sende UI-Meldungen zu folgendem Inhalt

Some pages should sometimes follow the content language, especially for multilingual sites. This can be controlled with the setting $wgForceUIMsgAsContentMsgManual:$wgForceUIMsgAsContentMsg. Each message overridden in this way must be explicitly given, for example to let the sidebar link to versions given by the content language for the main page and the portal page add the following to

LocalSettings.php

code
$wgForceUIMsgAsContentMsg = [ 'mainpage', 'portal-url' ];

Hinzufügen oder Entfernen von Abschnitten zur Werkzeugkiste (toolbox) (JavaScript)

The toolbox, which appears under the search bar, is a dynamic element and cannot be easily customized without the use of skinning extensions (otherwise it requires programming in PHP.) If you still want to do so, you can copy skins/MonoBook.php, creating a new skin. You can then make a custom skin to generate these links in your preferred fashion.

Another JavaScript solution is below.

For this solution to work on the entire MediaWiki site, this script has to be copied to MediaWiki:Common.js (MediaWiki:Common.js is available for MediaWiki 1.9 +).

For this solution to work only for a specific user, add this script to Special:MyPage/common.js (or the JS page for the user's current skin, such as Special:MyPage/monobook.js).

Now simply configure which link should appear in which section. You also can remove some links if you want to.

code
function ModifySidebar( action, section, name, link ) {
	try {
		switch ( section ) {
			case 'languages':
				var target = 'p-lang';
				break;
			case 'toolbox':
				var target = 'p-tb';
				break;
			case 'navigation':
				var target = 'p-navigation';
				break;
			default:
				var target = 'p-' + section;
				break;
		}

if ( action == 'add' ) {
			var node = document.getElementById( target )
							   .getElementsByTagName( 'div' )[0]
							   .getElementsByTagName( 'ul' )[0];

var aNode = document.createElement( 'a' );
			var liNode = document.createElement( 'li' );

aNode.appendChild( document.createTextNode( name ) );
			aNode.setAttribute( 'href', link );
			liNode.appendChild( aNode );
			liNode.className = 'plainlinks';
			node.appendChild( liNode );
		}

if ( action == 'remove' ) {
			var list = document.getElementById( target )
							   .getElementsByTagName( 'div' )[0]
							   .getElementsByTagName( 'ul' )[0];

var listelements = list.getElementsByTagName( 'li' );

for ( var i = 0; i < listelements.length; i++ ) {
				if (
					listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
					listelements[i].getElementsByTagName( 'a' )[0].href == link
				)
				{
					list.removeChild( listelements[i] );
				}
			}
		}


} catch( e ) {
		// let's just ignore what's happened
		return;
	}
}

function CustomizeModificationsOfSidebar() {
	// adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox
	ModifySidebar( 'add', 'toolbox', 'CategoryTree', 'http://en.wikipedia.org/wiki/Special:CategoryTree' );
	// removes [[Special:Upload|Special:Upload]] from toolbox
	ModifySidebar( 'remove', 'toolbox', 'Upload file', 'http://en.wikipedia.org/wiki/Special:Upload' );
}

jQuery( CustomizeModificationsOfSidebar );
Usage
function CustomizeModificationsOfSidebar() has to be customized for adding or removing links in specific sections:
ModifySidebar( "action", "section", "name", "link" );
parameter value
action add to add a link; remove to remove a link
section navigation, toolbox, languages but also any other existing customized section; the given link will be added to or removed from this section
name contains the text of the link
link contains the URL of the link
restricting modifications to specific usergroups

If you want to restrict the modification of the links to a specific user group (e.g. bureaucrat), change

jQuery( CustomizeModificationsOfSidebar );

to

if ( mw.config.get( 'wgUserGroups', [] ).indexOf( 'bureaucrat' ) !== -1 ) {
	jQuery( CustomizeModificationsOfSidebar );
}

For restricting the modifications to IPs instead of a specific user group, use

if ( mw.config.get( 'wgUserGroups', [] ).indexOf( 'user' ) === -1 ) {
	jQuery( CustomizeModificationsOfSidebar );
}

Hinzufügen oder Entfernen von Abschnitten zur Werkzeugkiste (toolbox) (PHP)

You can add in your file LocalSettings.php the hook described on this page. With this, you can modify via MediaWiki:Sidebar the links in the toolbox panel (remove some links, change their name) and add custom links (e.g. add the "Recent changes" link there instead of the navigation panel.

Auf-/Zusammenklappen der Navigationsleiste durch alle Benutzer (nur der Mono-Bucheinband)

If you use the Monobook skin and don't want to miss the expandable menu bar from e.g. Vector skin, paste the following code into MediaWiki:Monobook.js of your wiki.

/////////////////////////////////////////////////////////
// Code snippet to make your sidebar items expandable  //
// Use this code ONLY for the Monobook skin.           //
/////////////////////////////////////////////////////////

$( document ).ready( function() {
	// Set the default expanded items by their headline
	var defaultExpandItems = ['Navigation', 'Orga'];
	// Set the basic-name for the cookies, which save the current state of expanding
	var expandCookieName = 'disdance_project_wiki_nav_expanded_';

var maxHeights = [];
	var expandeds = [];
	var labels = [];
	initNav();
});

function initNav() {
	$( '#p-logo' ).css({'position': 'relative', 'display': 'block'});
	$( '.generated-sidebar h5,#p-tb h5 ').each( function( i ) {
		var id = $( this ).parent().attr( 'id' );
		maxHeights[id] = $( this ).next( 'div' ).height();
		var str = $( this ).html();
		labels[id] = str;

if ( $.cookie( expandCookieName + id ) == 'false' ) {
			expandeds[id] = false;
			minimize( $( this ) );
		} else if ( $.cookie( expandCookieName + id ) == 'true' ) {
			expandeds[id] = true;
			maximize( $( this ) );
		} else if ( defaultExpandItems.indexOf( str ) == -1 ) {
			expandeds[id] = false;
			minimize( $( this ) );
		} else {
			expandeds[id] = true;
			maximize( $( this ) );
		}
		$( this ).css({'cursor': 'pointer'});
		$( this ).click( toggleNav );
	} );
}

function minimize( target ) {
	var id = $( target ).parent().attr( 'id' );
	// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
	$.cookie( expandCookieName + id, 'false', { expires: 7} );
	var str = labels[id] + '  ►';
	$( target ).next( 'div' ).animate({'height': '0px'});
	$( target ).html( str );
}

function maximize( target ) {
	var id = $( target ).parent().attr( 'id' );
	// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
	$.cookie( expandCookieName + id, 'true', { expires: 7} );
	var str = labels[id] + '  ▼';
	var newHeight = maxHeights[id];
	$( target ).next( 'div' ).animate({'height': newHeight + 'px'});
	$( target ).html( str );
}

function toggleNav( e ) {
	var id = $(e.target ).parent().attr( 'id' );
	expandeds[id] = !expandeds[id];
	if( expandeds[id] == true ) {
		maximize( e.target );
	} else {
		minimize( e.target );
	}
}

///////////////////////////////////////////////////////
///////////////////////////////////////////////////////

Navigationsleiste mit Mono-Bucheinband (CSS)

You can change the width of your sidebar by adding the following CSS rules to your MediaWiki:Monobook.css, note that this is an article, not a file. This changes the width to 15em, the actions position and portlet width should be an em or so less, so I've set them to 14em in this example.

/* increase sidebar width */
#column-content { margin-left: -15em; }
#column-content #content { margin-left: 15em; }
#p-logo a, #p-logo a:hover { width: 15em; }
#p-cactions { left: 14.5em; }
.portlet { width: 14em; }
div#column-content { margin-left: -14em; }
div#content { margin-left: 14em; }

Breite der Navigationsleiste im vektoriellem Einband (CSS)

You can change the width of your sidebar by adding the following CSS rules to your MediaWiki:Vector.css. The standard width in vector skin is 10em. The following example changes the width to 12em:

/* increase Vector sidebar width */
div#mw-panel { width: 12em; }
div#footer, #mw-head-base, div#content { margin-left: 12em; }
#left-navigation { margin-left: 12em; }

Änderung der Navigationsleisteninhalte, wenn angemeldet (PHP)

You can modify the sidebar using a hook. Create a small extension of your own or put the code directly into your LocalSettings.php file.

Some example code adding a 'navigation' sidebar block with a login link for logged out users.

Warnung Warnung: The sidebar's array is cached after this hook is run, if you use sidebar caching and do user specific things in this hook like something that only shows up when logged in or out it may end up cached and not look correctly for some users.
<?php
$wgHooks['SkinBuildSidebar'][] = 'lfHideSidebar';
function lfHideSidebar( $skin, &$bar ) {
	global $wgUser;
	// Hide sidebar for anonymous users
	if ( !$wgUser->isLoggedIn() ) {
		$bar = array(
			'navigation' => array(
				array(
					'text'   => wfMessage( 'login' ) -> text(),
					'href'   => SpecialPage::getTitleFor( 'Login' )->getLocalURL(),
					'id'     => 'n-login',
					'active' => ''
				)
			)
		);
	}
	return true;
}

Syntaxanalysefunktionen (parser) in der Navigationsleiste

Although it is not exactly recommended, the sidebar does support parser functions (such as ParserFunctions), provided the ** is outside the parser function, and the parser function does not span multiple lines. For example:

*Heading
**{{#ifeq:{{NAMESPACE}}|User|Page-to-link-to{{!}}text-to-show-on-user-page}}
**{{#ifeq:{{NAMESPACE}}|Talk|Another-Page-to-link-to{{!}}text-to-show-on-talk-page}}

works. However the following would not work since the parser function spans multiple lines:

*Heading
{{#ifeq:1|1|
**foo{{!}}
bar
|
**baz{{!}}fred
}}
Warnung Warnung: There is a bug on 1.18 where if a line on MediaWiki:Sidebar contains pipe characters (| ) before expanding parser functions, but not after expanding parser functions, an exception is thrown on all pages (bug 33321). If such a construction is accidentally introduced to the sidebar, it forces the user to revert MediaWiki:Sidebar using the API or edit.php. This is fixed in later versions of MediaWiki

Problemlösung

Änderungen werden nicht angezeigt

MediaWiki aggressively caches content if possible, which often causes the navigation bar to persist after changes. Purging the cache of affected pages should correct the situation. To perform a mass-purge of all caches at once, touch the LocalSettings.php file or truncate the objectcache table in your database (you may have to do both).

You also need to have $wgUseDatabaseMessages set to true.

If you are a user or average wiki admin, you will not be able to do the advanced stuff above to get changes to show up. If purging does not work either, you can sometimes still see CSS changes right away in preview (especially when changing your personal CSS). For example; changing the sidebar width, padding, or margins. Changes can take awhile to show up after saving though. If nothing shows up after awhile you may need to contact the overall wiki, or wiki farm, sysop.

Verweisbeschriftungen (link labels) kleingeschrieben

If your links are not being capitalized as intended, try adding spaces around the bar character; for example:

** http://www.example.com/download.php?file=44555 | Download

Abschnitte verschwinden oder zeigen unerwarteten Inhalt

If a section does not display or displays unexpected content, check that the header text isn't the name of an interface message by searching Special:AllMessages. If it is, use a different header text, or create a new interface message and use it.

For example, if you want to use "Sidebar" as header text, create the interface message "MediaWiki:Sidebar-header" containing only "Sidebar". Then, use * sidebar-header as header.

Sections are not displayed if there are no links of the form ** target | link text (e.g. when the target was forgotten).

Verweise ins Leer nach Aktualisierungen Special:Version

This will happen e.g., each time there are newer translations for your site language's sidebar items. One could add new redirect pages each time, but a better solution would be to use one's own sidebar item names instead of trying to keep track of the current MediaWiki translations.

Frühere Versionen von MediaWiki

If you have a pre-release version of 1.5 Beta, or earlier, it is still possible in some cases to edit the sidebar:

Siehe auch

References