This Forum has been archived

Visit the new Forums
Forums: Index Community Central Forum Monobook contribs tab
Fandom's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.

50px-Replacement filing cabinet.svg

Note: This topic has been unedited for 2492 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

Hi. I've been trying to get a tab to link to a user's contributions in monobook, so far I can only get it to display my username whenever I view a page. Is there a way I can get it to have the username of the userpage I'm viewing when I click it?

Here's the code I have:

$(document).ready(function() {
if (wgNamespaceNumber == '2' || wgNamespaceNumber == '3') {
$('#p-cactions ul').append('<li id="ca-contribs"><a title="Contributions for '+ wgPageName +'" href="/index.php?title=Special:Contributions/'+ wgPageName +'">Contributions</a></li>');

Thanks --Christalk 01:07, December 21, 2010 (UTC)

wgPageName will probably be the page name including the namespace (User:username), so you need to remove the namespace (wgCanonicalNamespace). Maybe you can use wgTitle instead? See MediaWiki Developer's Handbook/Add JavaScript/Predefined variables for some info. -- Fandyllic (talk · contr) 6:54 PM PST 20 Dec 2010
Thanks, wgTitle worked - also, thanks for the link, I could use that in the future if I run into any more problems. --Christalk 05:42, December 21, 2010 (UTC)
Thanks for the link indeed, i have added it to my handy-wiki-links's other section :)
⇐⇑©TriMoon™TalkHandyWikiLinks @ 19:08, December 21, 2010 (UTC)
Did you considered user subpages? Try that:
var user = window.wgTitle;
var slash = user.indexOf('/');
if (slash != -1) {
	user = user.substr(0, slash);
Also, I developed an extension for adding useful links of the user and avatar: [1]. It has no translations available, but it's easy to customize. I had no time to document it, but you know, GPL comes with no warranty :) --Ciencia Al Poder (talk) -WikiDex 20:37, December 21, 2010 (UTC)
Can you link to the source? It should be relatively easy to translate. -- Fandyllic (talk · contr) 1:55 PM PST 21 Dec 2010
Yup, w:c:es.pokemon:MediaWiki:Common.js/Clases/UserWikiInfo.js. I made it so it can be easy to customize or translate, changing only the params at the top of the object. You'll also need to create w:c:es.pokemon:MediaWiki:UserWikiInfoContribs to properly display the "good contribs ratio" bar to select which namespaces count for the "useful contribs" — way better than user badges :)
I made a sort of installation guide in spanish at w:c:dev:User:Ciencia_Al_Poder/UserWikiInfo/es with the CSS needed and how to place the JS. --Ciencia Al Poder (talk) -WikiDex 10:20, December 22, 2010 (UTC)