Variable in MediaWiki for current user

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 maybe another way) to get the current user who logged in to the wiki, i.e. something like

 {{USERNAME}} 

context: an attempt to use the #ask query in Semantic MediaWiki to narrow down the list of resulting pages to show those that 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.}} 
+4
source share
2 answers

There are many extensions for such as GetUserName , MyVariables , UserInfo . The whole concept of displaying custom names is not compatible with page caching (you need to analyze the page every time someone looks at it), so this is usually not a good idea.

+2
source

I was just looking for the same thing and looking to see if I could do this without extensions. There seems to be a default function that allows this if you want it to be part of writing a static version on the page, rather than "Hello, Username!". (This is the last time why they did not implement it as a standard variable, as it causes caching problems.)

The Wikimedia function request T14733 allows:

 {{subst:REVISIONUSER}} 

{{REVISIONUSER}} will dynamically display the last editor, which is usually not what you want. But if you want, for example, to create a template that includes a user descriptor as part of some inserted text, this should complete the task. I think in your example above,

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

(I'm not sure that the Semantic Mediawiki will force you to avoid substitutions, but if so, further instructions are in the Manual: Substitution, Multilevel substitution section .)

0
source

Source: https://habr.com/ru/post/1440198/


All Articles