Template:USERNAME/doc: Difference between revisions
(Copied from w:c:templates) |
m (Updated.) |
||
Line 3: | Line 3: | ||
;Syntax |
;Syntax |
||
: {{ |
: {{T|USERNAME|alt text}} |
||
: Optional '''''alt text''''' is what is displayed when no user is logged in. If nothing is supplied as alt text, users will see "<nowiki><insert name here></nowiki>" when not logged in. |
: Optional '''''alt text''''' is what is displayed when no user is logged in. If nothing is supplied as alt text, users will see "<nowiki><insert name here></nowiki>" when not logged in. |
||
Line 21: | Line 21: | ||
;Dependencies |
;Dependencies |
||
: This template requires you to add the following to your wiki's [[MediaWiki:Common.js]]. |
: This template requires you to add the following to your wiki's [[MediaWiki:Common.js]]. |
||
<syntaxhighlight lang="javascript" style="padding:10px; background-color:# |
<syntaxhighlight lang="javascript" style="padding:10px; background-color:#F5F5F5"> |
||
/* |
/* |
||
Replaces {{USERNAME}} with the name of the user browsing the page. |
Replaces {{USERNAME}} with the name of the user browsing the page. |
||
Line 31: | Line 31: | ||
$('span.insertusername').text(mw.config.get('wgUserName')); |
$('span.insertusername').text(mw.config.get('wgUserName')); |
||
}); |
}); |
||
</syntaxhighlight> |
</syntaxhighlight><includeonly> |
||
<includeonly> |
|||
[[Category:General wiki templates]] |
[[Category:General wiki templates]] |
||
</includeonly><noinclude> |
</includeonly><noinclude> |
||
[[Category:Template documentation]] |
[[Category:Template documentation]] |
Latest revision as of 12:17, 18 August 2021
- Description
- Adds the username of the registered Wikia user who is viewing the page. If no user is logged in, the supplied alt text is displayed instead.
- Syntax
- {{USERNAME|<alt text>}}
- Optional alt text is what is displayed when no user is logged in. If nothing is supplied as alt text, users will see "<insert name here>" when not logged in.
- Examples
{{USERNAME}} is the best.
- Gives…
- <insert name here> is the best.
- If not logged in, you see…
- <insert name here> is the best.
- Gives…
[[Special:Mypage|{{USERNAME|Visitor}}'s userpage is good too]].
- Gives…
- If not logged in, you see…
- Dependencies
- This template requires you to add the following to your wiki's MediaWiki:Common.js.
/*
Replaces {{USERNAME}} with the name of the user browsing the page.
Requires copying Template:USERNAME.
*/
$(function() {
if (window.disableUsernameReplace || mw.config.get('wgUserName') === null) { return; }
$('span.insertusername').text(mw.config.get('wgUserName'));
});