Pergunta

In MediaWiki, you can use a variable ("Magic Word") such as

{{PAGENAME}}

or

{{REVISIONDAY}}

to get specific information related to the current page being viewed. Is there a similar variable (or perhaps a different way) to get the current user who is logged in to the wiki, i.e. something like

{{USERNAME}}

context: Trying to use the #ask query in Semantic MediaWiki to narrow the list of resulting pages to show those only the user has created or edited:

{{#ask: [[Case Reflection:+]] [[Contributing User::{{USERNAME}}]]
 | format=template
 | template=Case Reflection Form Summary
 | link=all
 | sort=Last Edited
 | order=DESC
 | default=You have no case reflections related to this Case Study.}}
Foi útil?

Solução

There are a bunch of extensions for that such as GetUserName, MyVariables, UserInfo. The whole concept of showing usernames is incompatible with page caching though (you need to parse the page again every time someone looks at it) so generally not a good idea.

Outras dicas

I was just searching for the same thing, and looking to see if I could do it without extensions. It looks like there's a default feature that allows this, as long as you want it as part of writing a static version to a page, not to say "Hello, Username!" (That last case is why they have not implemented it as a standard variable, because it causes caching problems.)

Wikimedia feature request T14733 resolves with:

{{subst:REVISIONUSER}}

{{REVISIONUSER}} will dynamically show the last editor, which is usually not what you want. But if you want, for example, to make a template that includes the user's handle as part of some inserted text, this should do the job. I think in your example above,

[[Contributing User::{{subst:REVISIONUSER}}]]

(I'm not sure if Semantic Mediawiki will make you escape out the substitutions, but if it does, further instructions are at Manual:Substitution, Multilevel substitution section.)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top