Manual:Interface/Sidebar/Hacks/cs

Rozsah

Tato stránka obsahuje seznam hacků, které byly dříve zmíněny v Příručka:Rozhraní/Postranní menu.

Změna obsahu postranního panelu po přihlášení (PHP)

In your LocalSettings.php file, use the SkinBuildSidebar hook to modify the sidebar. Následující funkci použijte pro kontrolu $wgUser->isLoggedIn() a volání jiné systémové zprávy než 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;
}

Pak ve vaší wiki přejděte na stránku MediaWiki:anon_sidebar a vytvořte nový postranní panel.

Povolení značky wiki

Mnoho lidí se ptá na oddělení podpory, jak vložit libovolný wikitext do postranního panelu. Vezměte si kód z výše uvedeného příkladu. 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.

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