Manual: Interfaz/Barra lateral

From mediawiki.org
This page is a translated version of the page Manual:Interface/Sidebar and the translation is 27% complete.
Outdated translations are marked like this.
Ejemplo de barra lateral
See also: Manual:Remove Tabs

MediaWiki:Sidebar define la barra de navegación, la cual provee enlaces a la mayoría de los lugares en la wiki y suministra a los administradores del sitio un lugar para adicionar una colección constante de enlaces. Por ejemplo, la mayoría de las wikis enlazarán a la página de discusión de su comunidad y a algunas herramientas útiles. The navigation bar provides links to the most important locations in the wiki and supplies site administrators with a place to add an important collection of links. For instance, most wikis will link to their community discussion page and some useful tool pages.

Las skins Monobook y Vector colocan la barra de navegación arriba a la izquierda (top-right for right-to-left languages) junto a la barra de búsqueda y a la caja de herramientas, pero la ubicación puede ser diferente en otras skins. Esta barra lateral no se muestra a usuarios de móvil (p. ej. la versión del sitio producida por Extensión:MobileFrontend / Skin:MinervaNeue ). Usa el gancho MobileMenu para eso.

Personalizar la barra lateral

Para personalizar la MediaWiki:Sidebar en un wiki, primero necesita estar registrado con un usuario que tenga el permiso editinterface - Esto está habilitado por defecto para los administradores.[1]

You can access MediaWiki:Sidebar by either:

  • Going to http://yourdomain/wiki/index.php?title=MediaWiki:Sidebar&action=edit in your browser.
  • Typing MediaWiki:Sidebar in search bar, and validating with Enter.
  • From Special:AllMessages, searching for "side".

A continuación se muestra un código de ejemplo para una barra lateral en MediaWiki:Sidebar:

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

Este ejemplo mostrará la siguiente barra lateral:

Ejemplo de barra lateral
Si usted tiene que crear una nueva página, se le presentará el contenido por defecto de la barra lateral en el editor. Para crear exitosamente una página MediaWiki:Sidebar, necesita cambiar el contenido antes de salvar.

Dividiendo la barra de navegación en nuevas secciones

La barra de navegación puede estar dividida en secciones, cada una con su propio encabezado. Esto se hace agregando un asterisco.

El encabezado para cada sección es tomado desde la lista de elementos del primer nivel ("navigation" y "new heading" en el ejemplo de arriba). Si este texto corresponde al nombre de un mensaje de la interfaz (una página existente en ese título en la MediaWiki namespace), entonces el texto de esa página es usado como una etiqueta; de lo contrario, el título del encabezado se utiliza tal cual. Please note the {{int:}} magic word does not work since it is useless: MediaWiki automatically looks for a translation to display before to fallback to the default message.

In the example above, * navigation and * new heading are section headings.

Añadiendo enlaces a la barra lateral

Links are created with 2 asterisks (called Second-level list elements). Por ejemplo:

** <span lang="en" dir="ltr" class="mw-content-ltr">target</span>|<span lang="en" dir="ltr" class="mw-content-ltr">link text</span>
objetivo
El objetivo del enlace puede ser el nombre de un mensaje de interfaz (una página en el MediaWiki namespace) o una página wiki, o un enlace externo. En cualquier caso, el enlace puede ser interno, interwiki o externo.[2]
Do the following to determine the target:
  1. Llamar el texto objetivo.
  2. Si hay uno existente o un mensaje de interfaz por defecto con ese nombre, use el contenido de ese mensaje en vez del texto objetivo.
  3. Si la salida del paso anterior es una URL valida (comenzando con http:// u otro URL protocol), el enlace apuntará a esa URL.
  4. si no, se tratará como el enlace objetivo de un wikilink (enlazando a ese nombre de página o interwiki).
  5. En caso de que termine enlazando a '-', toda la entrada es removida de la barra lateral (eso es útil para remover una entrada en todos los lenguajes al cambiar el mensaje que tiene el enlace).
Ejemplos:
  • "** portal-url|portal" usa el texto de MediaWiki:Portal-url (el cual contiene "Project:Community portal")
  • "** https://www.mediawiki.org|MediaWiki home" links to https://www.mediawiki.org since this is a valid URL.
  • "** Special:RecentChanges|Recent changes" enlace a Special:RecentChanges, ya que no hay un mensaje de interfaz con ese nombre.
  • "** w:Foo|Some interwiki page" enlaza a w:Foo por la misma razón.
enlace de texto
El enlace de texto puede ser el mismo de un mensaje de interfaz (página en el the MediaWiki namespace) o texto plano.
  • Si el enlace de texto es el nombre de un mensaje de interfaz existente o por defecto, el contenido de ese mensaje será usado. Mediawiki verificará las versiones localizadas; por ejemplo, si el lenguaje actual es fr (Frances) y el enlace de texto es el mensaje de interfaz "forum", este verificará "forum/fr" antes de usar "forum".
  • En cualquier caso, el enlace de texto es usado como destino.
  • Note que el enlace de texto no es opcional como los enlaces en una wiki normal. Si falta el enlace de texto, el elemento se omite.
El texto del link puede ser el nombre de un mensaje de la interfaz (una página en el espacio de nombres MediaWiki) o texto plano.
  • 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.
Ejemplos:
  • ** Homepage|mainpage uses MediaWiki:Mainpage (which contains "MediaWiki").
  • ** Special:Recentchanges|Recent changes uses "Recent changes", since there is no interface message of that name.

Orden de las secciones (elementos)

Some skins allow customizing the order of some special elements, like the search bar, toolbox, and languages. That can be done by adding the special keywords SEARCH, TOOLBOX and LANGUAGES respectively, to MediaWiki:Sidebar using the heading syntax.

However, some skins like MonoBook no longer support defining the position of the search element, and the search element is placed right after the first section of the sidebar instead. In that case, to move the search element at the top, the workaround is to define an empty leading section. Por ejemplo:

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

Note that some skins may display the first section differently, or place some element between the first and the second section (if any).

Tooltips and Accesskey

A tooltip is a message which appears when a cursor is positioned over an icon, image, hyperlink, or other element in a graphical user interface.

If you add an item to the sidebar, it will have no "tooltip". But you can create a tooltip by doing the following:[3]

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

An access key or accesskey allows a computer user to immediately jump to a specific part of a web page via the keyboard.

Accesskeys can also be created by doing the following:

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

Ejemplo:

Traducciones

Usted puede traducir las cadenas, la cual usted usa, editando las páginas de acuerdo al namespace en la MediaWiki .

Ejemplo: La cadena, la cual reemplazará el elemento llamado "mainpage", es tomado de MediaWiki:Mainpage. Para configurar/cambiar este texto para los usuarios, quienes despliegan su wiki en Alemán, puede colocar el texto de acuerdo a la página MediaWiki:Mainpage/de.

De esa manera usted puede fácilmente traducir esos textos a través de la interfaz de la MediaWiki.

Por favor tenga en cuenta que la MediaWiki usará por defecto el contenido de la página en la barra lateral ese idioma, el cual corresponde al idioma por defecto de su wiki. Así, si su wiki e.g. utiliza el Francés como idioma por defecto, edite MediaWiki:Mainpage/fr para mostrar una barra lateral modificada a todos los usuarios, quienes no han cambiado su configuración de idioma y para todos los usuarios anónimos.

Para traducciones más avanzadas, ver Ayuda:Extensión:Translate/Traducción de elementos sin estructura .

Personalización avanzada

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.

Remove the Sidebar and main logo at MediaWiki:Sidebar

To completely remove the sidebar and logo:

Blank the MediaWiki:Sidebar page and save.

Then add:

#column-content { margin: 0 0 1em 0; }
#content { margin: 0 0 0 0; }
#p-cactions { left: .1em; }

This moves the main text of your wiki to the left.

Completely remove the sidebar, tabs and search bar

See also: Manual:Remove Tabs

Deletes the logo, and the entire sidebar:

#p-logo, .generated-sidebar, #p-lang, #p-tb  { display:none; }

Deletes the search bar:

#p-search { display:none; }

Deletes the talk tab:

#ca-talk { display:none!important; }

Deletes the Page tab:

#ca-nstab-main { display:none!important; }

Force UI-messages to follow content

Some pages should sometimes follow the content language, especially for multilingual sites. This can be controlled with the setting $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' ];

Add or remove toolbox sections (JavaScript)

The toolbox appears on the left under MediaWiki:Sidebar. The toolbox is a dynamic element requiring programmatic methods such as skin extensions, PHP (see skins/MonoBook.php and creating a new skin) or JavaScript.

The JavaScript solution uses User:{username}/common.js / MediaWiki:Common.js, available for MediaWiki 1.9+.

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', 'https://en.wikipedia.org/wiki/Special:CategoryTree' );
	// removes [[Special:Upload|Special:Upload]] from toolbox
	ModifySidebar( 'remove', 'toolbox', 'Upload file', 'https://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" );
parámetro 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 );
}

Add or remove toolbox sections (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).

Make expanding/collapsing sidebar for all users (Monobook skin only)

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 );
	}
}

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

Sidebar width in Monobook skin (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; }
#column-content { margin-left: -14em; }
#content.mw-body { margin-left: 14em; }

Change sidebar content when logged in (PHP)

Install and configure the DynamicSidebar extension.

Parser functions in sidebar

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
}}

Troubleshooting

Changes not showing up

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. Also, if your links don't have a | in them, they will not show up because of this line of code in Skin.php: if ( strpos( $line, '|' ) !== false ) {

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.

Lowercase link labels

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

Sections disappear or show unexpected content

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).

Broken links after updating 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.

See also

References

  1. (Para información sobre asignar un permiso a grupos o usuarios, ver Manual:Derechos de usuarios .) Luego, use un enlace a una página en su wiki, pero reemplace el título de su página wiki (e.g. Main_Page) en la URL/barra de direcciones con MediaWiki:Sidebar y cargue esa página - Usted debería ver ahora el contenido de la barra lateral. (Usted puede usar la sintaxis //yourdomain/yourwiki/index.php?title=MediaWiki:Sidebar&action=edit si usted utiliza URLs largas.) Si el contenido de la barra lateral ya ha sido modificado, usted simplemente puede dar clic sobre el enlace Editar o Editar código, de otra forma usted podría necesitar crear primero la página dando clic en Crear o Crear código.
  2. En algunos casos (tales como enlaces con el carácter "&"), un mensaje de interfaz es necesario. El enlace objetivo no puede ser dependiente del lenguaje de la interfaz configurada en las preferencias.
  3. http://www.kaarebmikkelsen.dk/?p=174