I came with the following, from my very limited php, and it does what
I'm looking for. There is probably a simpler way, but why make things
simple when we could make them complicated.
I create a basic extension named AmILogged.php (see below)
I have the ParserFunctions extension installed
Then in my wiki page, I have the following
{{#if: {{#WhoAmI: }} |
Information specific to logged user only
}}
This is my basic extension
<?php
$wgExtensionCredits['specialpage'][] = array(
'name' => 'AmILogged.php',
'author' =>'Gaetan Lord',
'description' => 'Return if the user is logged or anonymous'
);
# Define a setup function
$wgExtensionFunctions[] = 'wfAmILogged_Setup';
# Add a hook to initialise the magic word
$wgHooks['LanguageGetMagic'][] = 'wfAmILogged_Magic';
function wfAmILogged_Setup() {
global $wgParser;
$wgParser->setFunctionHook( 'AmILogged', 'wfAmILogged_Render'
);
}
function wfAmILogged_Magic( &$magicWords, $langCode ) {
$magicWords['AmILogged'] = array( 0, 'AmILogged' );
return true;
}
function wfAmILogged_Render( &$parser ) {
$parser->disableCache();
global $wgUser;
if ($wgUser->isLoggedIn()) {
return "1";
} else {
return "";
}
}
?>
On 7/20/07, Platonides <Platonides(a)gmail.com> wrote:
There's nothing like this. And, if you make an
extension for this,
you'll need to disable the parser cache (or modify it to take into
account the logged/unlogged state). Else, only the state of last purge
will be shown.
Content on sidebars is not stored on the article cache, so it's a better
place to put this kind of content (as the username does).
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l