Topic on Project:Support desk

Is there a way to make the TOC hidden by default?

7
Summary by 197.218.92.17
Txantimedia (talkcontribs)

I don't mean to get rid of it. I would refer that TOCs were displayed hidden with the show link being used to expand them. I've poked around through the manual and faq, but I haven't found anything about that. I guess another way to word this (which I've also searched for) is to have TOCs displayed collapsed by default, and opened by the viewer when desired. I do not want to use __NOTOC__. I want the TOC to be available, just not taking up the entire page before the article begins.

I could swear I saw this at Wikipedia somewhere, but I can't seem to find it.

Seb35 (talkcontribs)

I don’t have a complete answer but there is Manual:Table of contents where possibly there is a link to your desired feature. For Wikipedia, when you close the TOC, it is saved (in a cookie) and the next TOCs are then closed (well, it’s JavaScript, so it is closing when you open the page); when you re-open the TOC, it will then appear opened, etc.

Txantimedia (talkcontribs)

Thanks, @Seb35. I was not aware of the cookie setting. That would explain why I've seen it collapsed before. I looked through the Manual and the FAQ several times and didn't find the answer. I also found a template Template:TOC hidden, but it has no documentation, and the template code is beyond confusing.

The cookie info is useful.

#toc ul{

display.none;

}

Will permanently hide the TOC. That is NOT what I want.

197.218.92.17 (talkcontribs)

Nope, the CSS won't permanently hide the table of contents, a user can still click the show / hide link to show it.

Txantimedia (talkcontribs)

I put that code in MediaWiki:Common.css, and it didn't do anything. I put it in my personal common.css, and it didn't do anything. Perhaps I'm missing something?

Seb35's suggestion works though. If I close it, the next time I open the page, the TOC is closed.

Seb35 (talkcontribs)

I tried the CSS 197 gave, it works mostly but the word 'show' (or 'hide') is not always consistent with the real state.

If it does not work after you modified MediaWiki:Common.css, perhaps you need to force a hard refresh of the browser (Ctrl+F5 or Ctrl+R depending on the browser).

Txantimedia (talkcontribs)

That's probably true, but I like your fix better anyway. If you want it hidden when you open a page, hide it before you leave.