Template talk:TOC

Latest comment: 5 years ago by FeRDNYC in topic "Protecting" one section from the TOC

Special Table of Contents

edit

Hello, the mentioned special table of contents do not exist in this wiki, or at least I couldn't find it. Maybe this section needs some update? --Zabien (talk) 13:01, 13 November 2014 (UTC)Reply

Hello, same for me. Whare can I find this template?

Hello, same for me. Any news? --User:Bilou0675 (talk) 23 July 2015

User:Zabien, User:Bilou0675: It should be fixed now, thanks to User:Hashar. --ZFilipin (WMF) (talk) 10:43, 6 October 2016 (UTC)Reply

ZFilipin Ah, so it never existed. Thank you! :) ––Zabien (talk) 12:49, 12 October 2016 (UTC)Reply

hide only some headings from TOC?

edit

is it possible to hide sections from TOC on a per-section base? I want to have them structured and to have headings, but I do not want some sections to appear in the TOC, but cannot use limit, as the sections-to-hide are not all on the same level --80.146.245.99 08:34, 12 September 2016 (UTC)Reply

toclimit not working

edit

{{toclimit|limit=3}} isn't working here. Any fix?

"Protecting" one section from the TOC

edit

Hello, is there a mark-up that I can do to protect one section from the TOC? It is my main title that I do not want included in the TOC. My title is this:

Cochrane Acute and Emergency Care Review Group Network:
Reviews to be considered for Wikipedia:

If I can modify it so that it is not recognized by the TOC that would be great! Thanks! JenOttawa (talk) 18:15, 25 January 2019 (UTC)Reply

@JenOttawa: Hi, Jen. Well, first let me lead off with a disclaimer: You didn't say why you're asking and it's not really any of my business, but if this is for Wikipedia, you really shouldn't do this. The page TOC isn't just for "looks", it's also used by assistive screen readers for the vision-impaired, and all sorts of other code that cares about the structure of the page — reason enough to be very wary of messing with its contents. In fact, what I'm about to suggest is prohibited in the Wikipedia article space (see wikipedia:WP:PSEUDOHEAD). ...But if it's for some other use, then that doesn't apply, so go wild!
The simplest way to keep a heading out of the table of contents is to make it not a heading. In fact, Wikipedia has a template specifically for that purpose, which is heavily used in documentation and other behind-the-scenes code that needs to show examples of heading formatting, without actually creating a heading. (Because a real heading would show up in the TOC...) That template is {{fake heading}}.
You can see the documentation at its page, but basically you just give it a |level=num argument (where num is the heading level you want to emulate, from 1 to 6), and the text of the heading as the only other argument. It'll output something like this:
{{fake heading|level=2|Level 2 heading}} =>
Level 2 heading
Of course, I didn't actually use Template:fake heading above, because this is MediaWiki and not Wikipedia, so the template isn't available here. What I actually did was, I entered {{fake heading|level=2|Level 2 heading}} into Wikpedia's Special:ExpandTemplates, then copied the resulting HTML output and pasted it in here.
Which sort of brings me to my other point: Since (based on the code you provided above) you're planning to heavily modify the appearance of the heading anyway, there's really no reason you need to use any kind of heading — at all! You could just change the ‎<H4>...‎</H4> tags in your example code to ‎<P>...‎</P> (paragraph) tags. The text would look the same (because of the styling on both that element and the ‎<div>...‎</div> around it), but it would no longer register as a heading to the MediaWiki software.
Everything else would be unchanged — you can style ‎<P>...‎</P> tags just like headings, and you can set id= attributes on them and use those IDs as link destinations, (If you need to link to the non-heading heading with #get-start, for instance.) The only difference is, because it's not a heading, the TOC won't even know it exists.
Hope I was able to be of some help. -- FeRDNYC (talk) 22:04, 31 January 2019 (UTC)Reply
Hi @FeRDNYC: , thank you for taking the time to explain this to me. I also greatly appreciate your advice regarding Wikipedia article space and wikipedia:WP:PSEUDOHEAD. This is for a project page, so as far as I know, I am not breaking any rules and it will help me clean up my page as I did not mean for the title of the page to go into the TOC. I think that you may have answered my question in a couple of different ways and I will test this out tomorrow! Thank you again! JenOttawa (talk) 01:13, 1 February 2019 (UTC)Reply
@FeRDNYC: Your suggestion of changing to a paragraph worked very well. I am still learning wikicoding (and teaching myself). This solved my problem right away! Thank you again for your time!! JenOttawa (talk) 01:16, 1 February 2019 (UTC)Reply
@JenOttawa: Not a problem, glad to hear it worked out. And I agree, as you said for a project page the article-space rules like wikipedia:WP:PSEUDOHEAD don't apply, AFAIK it all comes down to consensus among the project members — if none of the other editors involved has any issue with the code, then it's perfectly fine! Best of luck with it. -- FeRDNYC (talk) 02:22, 1 February 2019 (UTC)Reply

TOC without any number

edit

What is the magic word to prevent the TOC to show numbers? I don't want to edit the Mediawiki:Commons.css, but I need to make a template for unnumbered TOC

Return to "TOC" page.