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

Ingo Gabriel internet at unitas.org
Mon Mar 27 05:12:35 UTC 2017


Hi,

indeed we didn't get managed the remaining toolbar title removed, too.
In the anon_page we only provide the site logo so it's not nice but ok
for us.

Hadn't time to dig into the skin code. May be it is hard coded or needs
an additional hook.

Just for completeness: We are currently on MW 1.26 using vector skin.

Ingo

Phil Legault schrieb:
> 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
>
>
>
> _______________________________________________
> 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





More information about the MediaWiki-l mailing list