[MediaWiki-l] Show a different sidebar for anonymous users

Phil Legault plegault at live.com
Fri Mar 24 15:39:54 UTC 2017


I'm using mediawiki 1.28.0

with this code I get on my toolbar, page tools has dropdown and text is just that.

text  Page tools



________________________________
From: MediaWiki-l <mediawiki-l-bounces at lists.wikimedia.org> on behalf of Ingo Gabriel <internet at unitas.org>
Sent: Friday, March 24, 2017 10:34 AM
To: MediaWiki announcements and site admin list
Subject: Re: [MediaWiki-l] Show a different sidebar for anonymous users

Just a hint: keep an eye on the unintentional line breaks introduced by
the mailing list/mail client ;)

Am 24.03.2017 um 15:25 schrieb Ingo Gabriel:
> Here we go.
>
> You will need to create an (empty) wiki page MediaWiki:Anon_sidebar or
> with any content you like to show in the sidebar to anonymous users.
>
> Good luck.
>
> # disable sidebar and toolbox for anonymous user
>
> # advice from mediawiki
> $wgEnableSidebarCache = false;
>
> $wgHooks['SkinBuildSidebar'][] = 'lfHideSidebar';
> /**
>  * Show a different sidebar for anonymous users.
>  * based on https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks
Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
www.mediawiki.org
This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...



>  *
>  * $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()->text(),
>     );
>   } else {
>     // No changes, just display the sidebar as usual.
>   }
>   return true;
> }
>
> $wgHooks['BaseTemplateToolbox'][] = 'modifyToolbox';
> /**
>  * Show a different toolbox in sidebar for anonymous users.
>  * based on https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox
User:Seb35/modifyToolbox - MediaWiki<https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox>
www.mediawiki.org
A small code snippet to allow administrators to modify the toolbox through MediaWiki:Sidebar. For example, move the "Recent changes" from the navigation to the toolbox:



>  *
>  * $skin template object
>  * $toolbox array Contains the array items, out of which the toolbox
> will be created (without headline)
>  * @return true
>  */
> function modifyToolbox( BaseTemplate $baseTemplate, array &$toolbox ) {
>     global $wgUser;
>
>     $emptyToolbox = array();
>
>     if ( !$wgUser->isLoggedIn() ) {
>         // provide empty toolbox
>         $toolbox = $emptyToolbox;
>     } else {
>        // No changes, just display the existing toolbox as usual.
>     }
>
>     return true;
> }
>
>
> Am 24.03.2017 um 15:19 schrieb Phil Legault:
>> If you could that would be great thanks
>>
>>
>>
>> ________________________________
>> From: MediaWiki-l <mediawiki-l-bounces at lists.wikimedia.org> on behalf of Ingo Gabriel <internet at unitas.org>
>> Sent: Friday, March 24, 2017 10:16 AM
>> To: MediaWiki announcements and site admin list
>> Subject: Re: [MediaWiki-l] Show a different sidebar for anonymous users
>>
>> We included the hook code and php function into the Localsettings.php
>>
>> and created the additional page for the anon-sidebar as wiki page
>>
>> I can provide the php code if interested in.
>>
>> Best regards
>> Ingo
>>
>> Am 24.03.2017 um 15:00 schrieb Phil Legault:
>>> Ya it seems I only get the text printout or it will just show "text" in the sidebar
>>>
>>>
>>> ________________________________
>>> From: MediaWiki-l <mediawiki-l-bounces at lists.wikimedia.org> on behalf of Ingo Gabriel <internet at unitas.org>
>>> Sent: Friday, March 24, 2017 8:43 AM
>>> To: MediaWiki announcements and site admin list
>>> Subject: Re: [MediaWiki-l] Show a different sidebar for anonymous users
>>>
>>> Hi,
>>>
>>> we are using the solution from
>>>
>>> https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks
Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
www.mediawiki.org
This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...



>> Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
www.mediawiki.org
This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...



>> www.mediawiki.org<http://www.mediawiki.org>
>> This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...
>>
>>
>>
>>> Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
www.mediawiki.org
This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...



>> Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
Manual:Interface/Sidebar/Hacks - MediaWiki<https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks>
www.mediawiki.org
This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...



>> www.mediawiki.org<http://www.mediawiki.org>
>> This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...
>>
>>
>>
>>> www.mediawiki.org<http://www.mediawiki.org>
>>> This page lists hacks that used to be mentioned in Manual:Interface/Sidebar. Change sidebar content when logged in (PHP) [edit source] In your LocalSettings.php file ...
>>>
>>>
>>>
>>> (you will need the modification from the talk page)
>>>
>>> We added additional handling of the toolbox section, too, by assigning
>>> similar solution to the hook $wgHooks['BaseTemplateToolbox'][] based on
>>> https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox
User:Seb35/modifyToolbox - MediaWiki<https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox>
www.mediawiki.org
A small code snippet to allow administrators to modify the toolbox through MediaWiki:Sidebar. For example, move the "Recent changes" from the navigation to the toolbox:



>>> User:Seb35/modifyToolbox - MediaWiki<https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox>
User:Seb35/modifyToolbox - MediaWiki<https://www.mediawiki.org/wiki/User:Seb35/modifyToolbox>
www.mediawiki.org
A small code snippet to allow administrators to modify the toolbox through MediaWiki:Sidebar. For example, move the "Recent changes" from the navigation to the toolbox:



>>> www.mediawiki.org<http://www.mediawiki.org>
>>> A small code snippet to allow administrators to modify the toolbox through MediaWiki:Sidebar. For example, move the "Recent changes" from the navigation to the toolbox:
>>>
>>>
>>>
>>>
>>> Ingo
>>>
>>> Am 24.03.2017 um 12:57 schrieb Phil Legault:
>>>> Has anyone found a solution for show different sidebar for anonymous users?
>>>>
>>>>
>>>> As always thanks for your help,
>>>>
>>>> Phil
>>>> _______________________________________________
>>>> MediaWiki-l mailing list
>>>> To unsubscribe, go to:
>>>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>>> --
>>> Ingo Gabriel
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> MediaWiki-l mailing list
>>> To unsubscribe, go to:
>>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>>> _______________________________________________
>>> MediaWiki-l mailing list
>>> To unsubscribe, go to:
>>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>>
>> _______________________________________________
>> MediaWiki-l mailing list
>> To unsubscribe, go to:
>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>> _______________________________________________
>> MediaWiki-l mailing list
>> To unsubscribe, go to:
>> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
>
> _______________________________________________
> MediaWiki-l mailing list
> To unsubscribe, go to:
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l


--
Ingo Gabriel

Verband der W.K.St.V. Unitas e.V.

Internetbeauftragter
Kooptiertes Mitglied im Beirat für Öffentlichkeitsarbeit, Nachwuchsförderung und Presse
Projektkoordinator „Unitas 3.1 – drei Prinzipien, ein gemeinsamer Weg“

E-Mail: internet at unitas.org
Homepage: http://www.unitas.org
Telefon privat: +49 721 21543
Telefon Mobil:  +49 173 9962143

Privatanschrift:
Leopoldstr. 37
76133 Karlsruhe

Sitz/Hausanschrift:
Jan-van-Werth-Str. 1
41564 Kaarst

Verbandsgeschäftsführer: Torsten Waibel
Vereinsregister VR 2101 beim Amtsgerichts Bonn


_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l


More information about the MediaWiki-l mailing list