Schmid, Wolfgang wrote:
@Jim
what you propose is a php based solution but I'm a beginner in php
programming and I'm looking for a wiki based solution without
programming own php code if possible.
The following code included from LocalSettigns.php would do:
$wgExtensionFunctions[] = 'wfIsLoggedFunctions';
function wfIsLoggedFunctions() {
global $wgParser, $wgExtIsLoggedFunctions;
$wgExtIsLoggedFunctions = new ExtIsLoggedFunctions();
$wgParser->setFunctionHook( 'iflogged', array(
&$wgExtIsLoggedFunctions , 'ifLogged' ) );
$wgParser->setFunctionHook( 'islogged', array(
&$wgExtIsLoggedFunctions , 'isLogged' ) );
}
class wgExtIsLoggedFunctions
{
function ifLogged( &$parser, $then = '', $else = '' )
{
global $wgUser;
$parser->disableCache();
if ($wgUser->isLoggedIn()) {
return $then;
} else {
return $else;
}
}
function isLogged( &$parser, $then = '', $else = '' )
{
global $wgUser;
$parser->disableCache();
return $wgUser->isLoggedIn();
}
}
?>
Usage:
{{#iflogged: Congratulations, you're a registered user.|You're
anonymous. Go to create an account!}}
I also added #islogged to return the raw boolean value.