This Forum has been archived

Visit the new Forums
Forums: Index Support Requests Tochidden help required
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 1581 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.


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 __NOTOC__ magic word. Just put it anywhere on the page. - Adan Aileron (talk) 00:16, August 21, 2011 (UTC)
__NOTOC__ 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. 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. Then again, the issue there is that MediaWiki remembers the state of the TOC. If a user navigates to a page and minimizes the TOC then navigates to a new page... the TOC on the new page is minimized as well and any code that you create to toggle the TOC will then again have the opposite effect. All in all, there is no real failsafe to ensure your code is doing what you intend it to do. You could try and talk with people from MediaWiki and see if a __MAGICWORD__ could be created for what you are wanting to accomplish. Rappy 23:25, August 23, 2011 (UTC)

(resetting indentation) Well it seems that what's in place now works as I want: annon or logged, when landing on the page, get a hidden TOC which they can display by clicking the "more" link, and it does not seem to be saved as a user preference or cookie. I'll see with other admin before using it on all the pages of that kind.

I personally use the TOC of a page very rarely, so that's why I wouldn't mind it being minimized by default.

The thing is: I really don't like having a whole lot of unused space when loading a page with the TOC so I like to 'Tocright' them. Visible but floating at the top right of the page. But now, having an infobox, placing the TOC above or below the infobox makes no sense. And having it before the first ==Title== may get the TOC too low, and still wasting a lot of space.

I'll try and come up with the best solution. That type of page always have the same structure with the same section titles, so maybe a custom hard-coded solution could do the trick.

I think one of the first problem that occurred what the time the common.js could be cached and used. I've made some changes to it but they didn't kick in until today.

Thanks a lot for your input, it helps figure out how to sort the problem :) Hunter789 00:18, August 24, 2011 (UTC)

Community content is available under CC-BY-SA unless otherwise noted.