Topic on Project:Support desk

Sidebar for anonymus User

7
217.116.64.60 (talkcontribs)

Hi,

In our old environment we implemented a second sidebar (usersidebar) for anonymous user - as described here: https://www.mediawiki.org/wiki/Manual:Interface/Sidebar/Hacks#Change_sidebar_content_when_logged_in_.28PHP.29

is there a way to get this in newer Versions of MediaWiki to work? I have seen the suggest here: https://www.mediawiki.org/wiki/Manual:Interface/Sidebar#Change_sidebar_content_when_logged_in_.28PHP.29

but this is maybe a good solution for one or two links, but not for a hole Sidebar?

Thanks in Advance!

87.123.63.88 (talkcontribs)
217.116.64.60 (talkcontribs)

Hi!

I have changed the code to:

$wgHooks['SkinBuildSidebar'][] = 'lfHideSidebar';

/**

* Modify the sidebar for anonymous users.

*

* $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 login link and a special anonymous sidebar.

$bar = array(

'anon' => array(

array(

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

'id' => 'anon-info',

)

)

);

} else {

// No changes, just display the sidebar as usual.

}

return true;

}

That gives me one Sidebar as i wish, but it can only display text, no links - is there a chance, that the content of "anon_sidebar" can be displayed as links, just as the normal sidebar?

Thanks in advance!

87.123.45.48 (talkcontribs)

The functions, which can be used on the text are plain(), text(), parse() and parseAsBlock(). In your code you have the line

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

Try to use this one instead:

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

This should parse the wikitext to HTML.

87.123.45.48 (talkcontribs)

Also I have updated the example HTML code, which you should add in your sidebar page, if you have your content parsed. Check out Manual:Interface/Sidebar/Hacks!

217.116.64.60 (talkcontribs)

Hi!

Unfortunately that wont work - with the code from you it only shows a Sidebar with the Heading (anon), when i add a

additionally "array" command it shows me the content of the sidebar, but only with text, not with links:

<code>

'anon' => array(

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

'id' => 'anon-info',

)

);

</code>

change to:

<code>

'anon' => array(

array(

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

'id' => 'anon-info',

)    

)

);

</code>

The "parse" command shows additionally something like <code> <li> </li> </code> between the text, but its not a link... I think its only a small thing what is missing here...

This post was hidden by 209.250.150.163 (history)
Reply to "Sidebar for anonymus User"