This Forum has been archivedVisit the new Forums
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)
- 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)
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)
- 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
(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)