Forum:Tochidden help required

Hello!

I'd like a way to hide TOCs on specific pages on a Wiki I edit. I've found something here and there which seems to do what I need. I've tried a basic copy-paste on the wiki I edit, with no success. I'm a bit puzzled right now because I don't have a clue what's missing, and where it's missing.

If anyone could help point out what's to be done to make it work, I'd greatly appreciate it :)

Thanks! Hunter789 21:48, August 20, 2011 (UTC)


 * You'll be wanting the magic word. Just put it anywhere on the page. - Adan Aileron (talk) 00:16, August 21, 2011 (UTC)


 * is when you do not want the TOC displayed at all on your page. However, I want the TOC to be there, but I want it to be hidden when the user lands on the page (like here). Hunter789 00:23, August 21, 2011 (UTC)


 * Sorry, I guess I misunderstood. In that case, you'll need to add the show/hide code from here to your MediaWiki:Common.js and MediaWiki:Wikia.css. I apologize for the oversight and hope this is better for what you wanted. - Adan Aileron (talk) 00:37, August 21, 2011 (UTC)


 * Woa this looks good! No worries :) I'll give it a try! Thanks a lot! Hunter789 00:41, August 21, 2011 (UTC)


 * Ok, it works... When I'm not logged in :P Hunter789 03:15, August 21, 2011 (UTC)


 * Actually, I'm not sure how it works at all, since you haven't actually added the Javascript to your MediaWiki:Common.js. Anyway, I've also found this other forum thread which is also relevant to your problem. - Adan Aileron (talk) 16:09, August 22, 2011 (UTC)

(indent reset) Humm, well looking at my MediaWiki:Common.js we can see that there are functions to collapse tables, even if it's not the one from dev.wikia. I've updated the Common.js lately to change the UserNameReplace function behavior, but it seems, when loading pages that Common.js uses an old version (UserNameReplace previously used YAHOO javascript toolkit). Moreover, I found out that when logged, Firefox dev consoles report a YAHOO not found error, and the same error is not reported when accessing the site while not logged.

So it seems the behavior is not the same when logged and not logged, and even if I updated Common.js, the script would not be updated when loaded for users.

Thanks for your input :) Hunter789 18:01, August 22, 2011 (UTC)


 * Anons see the TOC initially collapsed. Is that what you're wanting? A way to collapse the TOC for certain pages? Rappy 19:58, August 23, 2011 (UTC)


 * Yes, I want everyone to see the TOC initially collapsed on page load. Now I do see it collapsed too. There's magic around, that's fantastic! Unfortunately, I don't have enough mana to make it work by myself... Hunter789 20:17, August 23, 2011 (UTC)


 * And yes, only for certain pages, not for all pages. Hunter789 20:18, August 23, 2011 (UTC)


 * Personally, I would hate to have the TOC forcefully minimized when I go to a page. Setting this wiki-wide may cause an upset from some people. If it is confined to certain pages to increase readability/aesthetics I think it would be OK. I will look into how to do it. Using JS to run  on those page(s) should be sufficient... but there is no way to know if it was initially open or closed. Also, this would cause the opposite affect on ANON users as it would open the TOC rather than having it remain collapsed. You could add a hidden span via a template, (ie, ) that when found via JS, it could toggle the TOC for all users except ANONs. Rappy 23:25, August 23, 2011 (UTC)