Forum:How to force template on page using .CSS?

Hi there,

I'd like to add a simple box template to one specific page, but I'd like this to be done with .CSS code so no one can remove it (Protecting the page is not an option). It's not important if it shows up in the edit section or above the header, as long as it appears. Anyway to do this? -- Light Daxter -  Talk  20:39, June 17, 2010 (UTC)


 * Well technically people can block CSS (or any extra file) from loading. JS would be a better option in this case anyway - CSS isn't really designed to add content, but rather style existing content - though you could un-hide existing content on a certain page with CSS.  You could also do some tricky work with  in the MediaWiki:Sitenotice. -- 20:45, June 17, 2010 (UTC)

I'll try fiddling around with the sitenotice. But if it won't work, any idea what I need to put into .CSS or .JS? -- Light Daxter -  Talk  20:51, June 17, 2010 (UTC)

Scratch that, I don't have a clue how I would do it with, I barely know how templates work, let alone the more advanced parameters. -- Light Daxter -  Talk  20:53, June 17, 2010 (UTC)
 * For CSS you would need a DIV, probably in the sitenotice, that contains the content you want to show:

Message wiki text here
 * Then in your MediaWiki:Common.css (pretending the page in question is Special:RecentChanges) put:

.importantmessage { display:none; } .page-Special_RecentChanges .importantmessage { display:block !important; }
 * For JS you could just put in your MediaWiki:Common.js:

if (wgPageName == "Special:RecentChanges") $("#bodyContent").prepend("Message HTML here");
 * For the in-wiki logic, you would put in MediaWiki:Sitenotice:


 * Hope that helps. -- 21:02, June 17, 2010 (UTC)

Sitenotice doesn't appear in user/user talk namespace, sadly. So I tried the JS code, but it didn't work? http://jakanddaxter.wikia.com/wiki/User:Light_Daxter/monaco.js -- Light Daxter -  Talk  21:22, June 17, 2010 (UTC)
 * You have to use HTML in the JS, not wikitext. Also don't use linebreaks (or, if you must, put \ at the end of each line). -- 21:26, June 17, 2010 (UTC)

Tried that, but it still won't appear for me. Although there's a lone line break at my talk page now. Any clue? -- Light Daxter -  Talk  21:34, June 17, 2010 (UTC)
 * That's not full HTML. Also you will need to either refrain from using double quotes or escape them with \ -- 21:45, June 17, 2010 (UTC)

Hmm, well, I frankly don't have a clue about all of it. Someone else edited it for me, maybe he did it wrong? I hope someone can do it for me :C -- Light Daxter -  Talk  21:50, June 17, 2010 (UTC)