Manual:Interface/Sidebar/Hacks/nl

Doel

Deze pagina bevat een lijst van hacks die vroeger in Handleiding:Interface/Zijbalk werden genoemd.

Wijzigen inhoud zijbalk, wanneer ingelogd (PHP)

In your LocalSettings.php file, use the SkinBuildSidebar hook to modify the sidebar. Gebruik de volgende functie $wgUser->isLoggedIn() om te controleren of de gebruiker is ingelogd en vraag een ander systeembericht dan sidebar.

$wgEnableSidebarCache = false;

$wgHooks['SkinBuildSidebar'][] = 'lfHideSidebar';
/**
 * Show a different sidebar for anonymous users.
 * based on https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks
 *
 * $skin Skin object
 * $bar array Contains the array items, out of which the sidebar will be
created.
 * @return true
 */
function lfHideSidebar( $skin, &$bar ) {
  global $wgUser;
  // Hide sidebar for anonymous users
  if ( !$wgUser->isLoggedIn() ) {
    // Shows a special anonymous sidebar.
    $bar = array(
      // Returns the message text of that sidebar with only transformation done.
      // Setting array keys "text"; array keys "href" and "active" stay unset.
        'text' => wfMessage( 'anon_sidebar' )->inContentLanguage()->parse(),
        //'text' => wfMessage( 'anon_sidebar' )->inContentLanguage()->text(),
    );
  } else {
    // No changes, just display the sidebar as usual.
  }
  return true;
}

Ga vervolgens in uw wiki naar MediaWiki:anon_sidebar en maak uw nieuwe zijbalk aan.

Opmaak wiki toestaan

Veel mensen op de Helpdesk hebben gevraagd hoe men wikitext in de zijbalk kan plaatsen. Neem de code uit het bovenstaande voorbeeld. The text() function will return your page content unescaped, only {{-transformation is done. Instead of using the text() function, you can use the parse() function. Your page content will then be fully parsed from wikitext to HTML. Instead of

	'text' => wfMessage( 'anon_sidebar' )->inContentLanguage()->text(),

use this:

	'text' => wfMessage( 'anon_sidebar' )->inContentLanguage()->parse(),

That will allow your sidebar article to be proper wikitext.

Inhoud van MediaWiki:Anon_sidebar

In your sidebar, you will need to include the surrounding HTML tags to ensure the portlet is styled correctly. Your MediaWiki:Anon_Sidebar page content will need to look something like the following example after the change:

<div class="portal" role="navigation" id='p-support' aria-labelledby='p-support-label'>
<h3 id='p-navigation-label'>Navigation</h3>
<div class='body'>
*[[Main Page]]
*[[Community portal]]
*[{{fullurl:Special:Recentchanges}} Recent changes]
*[[Sandbox]]
*[[Help]]
</div>
</div>