Forum:Why won't these templates work on my wiki?

Hello, I am Pikapi, and I have yet another question. I was browsing Wookiepedia when I found two templates, Template:USERNAME and Template:Title. I tried putting them on my wiki but they didn't work. Can someone tell me why, or add a working one to Communipedia for me? -- " PiKaPi  talk   blog  20:51, July 2, 2010 (UTC)
 * They require you to add code to w:c:communipedia:MediaWiki:Common.js. -- 20:54, July 2, 2010 (UTC)
 * Hiya! Yep, Pcj is right. Check out the template pages at the Templates wiki for help: w:c:templates:Template:Title and w:c:templates:Template:USERNAME. These should get it working ;). Mark  ( talk ) 20:58, July 2, 2010 (UTC)

The title thing still doesn't work... -- " PiKaPi  talk   blog  22:08, July 2, 2010 (UTC) So can someone please help me out with this. Is it because I have that subtitle saying "From Communipedia, the Wiki-Styled Online Community"?


 * Please explain in detail exactly what you want to do. It sounds like you though the two templates mentioned above would do what you wanted, but if they are the reason we can't help you even if they work. -- Fandyllic  (talk &middot; contr) 9:31 AM PST 11 Jul 2010

I already have the USERNAME template thing figured out, but the Title templates don't work at all. -- " PiKaPi  talk   blog  16:43, July 11, 2010 (UTC)


 * I did some investigation and I don't think this template works anymore (or the Javascript is broken). The template is supposed to be used on w:c:templates:Template:Title/doc and I added the JS code to my w:c:templates:Special:MyPage/monaco.js which should make it work, but it doesn't. The template may use CSS classes or ids that are no longer in the Monaco skin.
 * Maybe you should contact Mark who said he fixed it once. -- Fandyllic  (talk &middot; contr) 9:57 AM PST 11 Jul 2010
 * Not sure what the problem is... I'm probably missing some JavaScript (wasn't written by me). I'll check it out. Mark  ( talk ) 19:54, July 11, 2010 (UTC)
 * Anybody with JavaScript experience around who can fix it? Mark  ( talk ) 20:02, July 11, 2010 (UTC)

Well it works on Wookipedia, but I don't know which part of Wookipedia's Common.js it is in...-- " PiKaPi  talk   blog  23:49, July 11, 2010 (UTC)

Soooo... can anyone help... --  Chris  talk   blog  16:55, July 15, 2010 (UTC)


 * Well it doesent appear to work on the templates wiki anyway (if it does what i think is supposed to). I did wonder if its designed to be used on a transcluded page as you are using it or is it supposed to be directly on the page it is used on ?
 * Sorry canot help as any more as I cannot be bothered to go searching for the one at wookipedia to look at how that one works if you cannot link to were you found it. And whats with everybody hiding behind different names from their Username ? - BulldozerD11 21:02, July 15, 2010 (UTC)

So nobody who is familiar with Javascript can just isolate the coding from Wookiepedia and give it to me!? --  Chris  talk   blog  16:57, July 19, 2010 (UTC)


 * Looks like this could be it from a quick scan down the common,JS at Starwars wikia rurned up this code,  but I dont know anything about JS to fix any problems with it.

// ============================================================ // BEGIN JavaScript title rewrite -- jQuery version by Grunny

function rewriteTitle { if( typeof( window.SKIP_TITLE_REWRITE ) != 'undefined' && window.SKIP_TITLE_REWRITE ) { return; }

if( $('#title-meta').length == 0 ) { return; }

var newTitle = $('#title-meta').html; $('.firstHeading').html(' ' + newTitle + ' '); $('.firstHeading').attr('style','text-align:' + $('#title-align').html + ';'); }

function showEras(className) { if( typeof( SKIP_ERAS ) != 'undefined' && SKIP_ERAS ) return;

var titleDiv = document.getElementById( className );

if( titleDiv == null || titleDiv == undefined ) return;

var cloneNode = titleDiv.cloneNode(true); var firstHeading = getFirstHeading; firstHeading.insertBefore(cloneNode, firstHeading.childNodes[0]); cloneNode.style.display = "block"; } // END JavaScript title rewrite
 * A link to the site would have been useful as a search for wookipedia turns up several wikis non actualy called wookipedia But starwars wikia is apparently wookipedia ! - BulldozerD11 18:51, July 19, 2010 (UTC)


 * This has been a problem for awhile. I believe wookieepedia.com (notice the 2nd 'e') redirects to starwars.wikia.com. Unfortunately, wookiepedia.com goes to a Star Wars merchandise site. Very confusing. -- Fandyllic  (talk &middot; contr) 5:48 PM PST 19 Jul 2010

It doesn't work either. --  Chris  talk   blog  20:02, July 20, 2010 (UTC)


 * What is "It"? -- Fandyllic  (talk &middot; contr) 1:13 PM PST 20 Jul 2010
 * Does your wiki have jQuery installed? jQuery is a javascript toolkit that that code sayins it needs. -- 00:22, July 21, 2010 (UTC)

About the wokiepedia confusion, I meant the wikia of course, and "It", Fandyllic, is the code listed above (kinda hard to misunderstand). You guys make me want to hurt myself! And for Roguebfl's question; no, I don't thing that anything called jQuery has been installed. --  Chris  talk   blog  15:24, July 21, 2010 (UTC)


 * Hard to help the unappreciative. That said, you should confirm with Wikia whether JQuery is installed on your wikia or not, because the code above will definitely not work without JQuery. I thought for some reason JQuery was a browser thing and not necessarily needed to be loaded by a website, though. -- Fandyllic  (talk &middot; contr) 8:29 AM PST 21 Jul 2010

Yeh, ok I'll ask. Well, thanks. :p --  Chris  talk   blog  17:33, July 21, 2010 (UTC)

Yes, jQuery is loaded on all pages on all wikis. Its what powers most of Wikia's interfaces. Also, http://docs.jquery.com/Main_Page --Uberfuzzy 17:41, July 21, 2010 (UTC)

So now I need the JavaScript code that references the JQuery library for it to work. Can someone please find me this code?--  Chris  talk   blog  14:55, July 23, 2010 (UTC)


 * The Javascript code block posted by BulldozerD11 above is the one that uses JQuery (well you don't the showEras function, I think) for the title stuff. -- Fandyllic  (talk &middot; contr) 10:20 AM PST 23 Jul 2010

Well I have it, and neither this, nor any other code for it works.--  Chris  talk   blog  22:55, July 23, 2010 (UTC)


 * It can't work because the code quoted above is incomplete (but in turn includes code which is not needed for the title rewrite). The following should work:

 function rewriteTitle { if( typeof( window.SKIP_TITLE_REWRITE ) != 'undefined' && window.SKIP_TITLE_REWRITE ) { return; }

if( $('#title-meta').length == 0 ) { return; }

var newTitle = $('#title-meta').html; $('.firstHeading').html(' ' + newTitle + ' '); $('.firstHeading').attr('style','text-align:' + $('#title-align').html + ';'); }

addOnloadHook(rewriteTitle);
 * Without the last line, the function to rewrite the title is present but never executed. -- Porter21 (talk) 23:25, July 23, 2010 (UTC)


 * Thanks Porter21 for explaining why it would not work - Wookipedias JSe file is obviously messed up then as i copied the section as marked in the file with comments, after nobody had responded for several days to pikapi. Note: I did add a disclaimer here that i know nothing about JS, so it was 'pasted' as is !! at least we know what to look for next time.  - BulldozerD11 00:17, July 24, 2010 (UTC)


 * I certainly didn't want to criticize you for trying to help, I was merely pointing out why it didn't work so people know what to look for next time :) Wookieepedia's JS file isn't messed up - they just use a more advanced method to execute all the "on page load" functions (the "loadFunc" stuff at the top of their MediaWiki:Common.js); "rewriteTitle" is called in there. -- Porter21 (talk) 07:31, July 24, 2010 (UTC)

Thank you, I'll give it a try. --  Chris  talk   blog  15:49, July 26, 2010 (UTC)

That code dosn't work either. When I add to a page, it only takes away the edit option next to the title. Nor does the title replace work either. Maybe you should familiarize yourselves with Maybe you should familiarize yourselves with my version of the template first. The strange part is that the code seemed to have worked on the Template:Title page once, even though it still doesn't anywhere else. --  Chris  talk   blog  16:00, July 26, 2010 (UTC)