Jump to content

Template talk:TOC top

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Edit request

[edit]

I propose changing the <h2> section format to something else. the issue is that when this template is used as a section table of contents, the 'contents' appears as a section in the main ToC. Note that Template:Compact ToC does not currently have this problem, since it doesn't use <h2>Contents</h2>. For an example, see United States House of Representatives elections, 1994 or List of U.S. Wilderness Areas. Notice that in List of U.S. Wilderness Areas, the "contents" section only appears once, even though there are two section ToCs. The reason is that only the first one is using this template (and hence <h2>Contents</h2>), while the second is not using <h2>Contents</h2>. We could also consider some sort of a 'span' around the contents, which has similar class formatting. I have put a modified version of this template in the sandbox. Frietjes (talk) 16:47, 9 March 2012 (UTC)[reply]

My aim was to get the output as close to an auto-generated TOC as possible. Auto-generated TOCs use an H2. Indeed, {{compact TOC}} is on my to-do list for conversion to use this code, as that will give it collapsible support. The present sandbox code wraps the hide link onto a new line, so I don't think it's really suitable. That said, I've asked the admin who fully-protected this template yesterday to undo that, as it's a little premature considering there's still work being done to it. Chris Cunningham (user:thumperward) (talk) 11:17, 10 March 2012 (UTC)[reply]
yes, I am all for making the output nearly the identical, but we should be able to do this without having the "contents" appear in the table of contents. I will see if I can modify the sandbox version to do this without compromising the appearance. Frietjes (talk) 14:02, 10 March 2012 (UTC)[reply]
I fixed the wrapping for the hide links by removing the newlines between the div and the "contents", see this version. I will work on the bolding next. Frietjes (talk) 14:33, 10 March 2012 (UTC)[reply]
okay, I believe I figured it out. this version looks nearly identical to what we had before and the 'show/hide' functionality is also identical. so, as far as I can tell, this should work now. let me know if you have any more concerns or suggestions or comments or whatever. the tests are sandbox version by itself vs live version by itself and sandbox version with another TOC template and live version with another TOC template. the only visual difference that I see is that the sandbox version suppresses the 'Contents' section in the double TOC case, which is what we want. thank you. Frietjes (talk) 14:42, 10 March 2012 (UTC)[reply]
 Done. We really need to examine what happens with multiple TOCs, because right now the output doesn't actually validate (the page will have more than one element with id="toc". However, that's always been the case, so let's ignore it for now. Also worth seeing if the use of an H2 in the auto-generated TOC should be changed to just a bold span as here, as I'm still somewhat concerned that the appearance of TOCs now varies significantly when no stylesheet is applied. In fact, I'm very concerned about this, and am rather wavering on the idea that the correct fix here would be for the auto-generate TOC in MediaWiki itself to be modified to suppress TOC H2s. Chris Cunningham (user:thumperward) (talk) 11:03, 11 March 2012 (UTC)[reply]
thank you. yes, I agree that a better fix would be in the autogenerated TOC, and probably for it not to use h2 for the heading. we should be able to have this template generate the exact same thing and for it to behave properly. Frietjes (talk) 18:28, 12 March 2012 (UTC)[reply]

align=center

[edit]

The template currently does not implement align=center properly. The style gets constructed as "float:center;" which is not legal CSS and does not center the box. This bug affects {{Category TOC}} too.

The fix is provided in the sandbox. Test cases (three of them) look OK (i.e. the template should work as advertized when align is set to "center", and in all other cases it should work the same as before). GregorB (talk) 15:16, 9 October 2013 (UTC)[reply]

are you sure you want clear:both for the center align case? this means that an infobox or sidebar cannot float next to it? other templates, like {{nutritional value}} have clear:none for this case. I updated the sandbox to make the logic a bit more clear (at least for me). Frietjes (talk) 17:19, 9 October 2013 (UTC)[reply]
I wasn't sure myself, but you do have a point... Anyway, whoever wants margin clear is able to get it independently from this template so clear:none looks like a reasonable default after all. Your changes look OK and so do the test cases so I guess this is good to go. GregorB (talk) 20:02, 9 October 2013 (UTC)[reply]
DoneMr. Stradivarius ♪ talk ♪ 09:00, 11 October 2013 (UTC)[reply]

Vertical margin increase?

[edit]

On the majority of articles, table of contents box is positioned too close to the lead section, making that specific part of articles layout looking not so nice. How about having a bit more spacing there, something like adding style="margin-top: 0.9em;" to the outer <div> element? It would make positioning of the TOC box much, much better... I've been running that through my User:Dsimic/common.css for about a week, and it looks and works great. Thoughts? -- Dsimic (talk) 16:44, 17 November 2013 (UTC)[reply]

Not done: please establish a consensus for this alteration before using the {{edit protected}} template. In addition to which, the spacing is not controlled by this template, but by the CSS that are applied to the <div id="toc" class="toc"> tag. --Redrose64 (talk) 20:04, 19 November 2013 (UTC)[reply]
@Redrose64: Thank you for the explanation. Could you, please, point me into where should I place a discussion regarding proposing this change? I guess this isn't the right place for that. -- Dsimic (talk) 20:26, 19 November 2013 (UTC)[reply]
MediaWiki talk:Common.css, if the css is in MediaWiki:Common.css. Frietjes (talk) 20:52, 19 November 2013 (UTC)[reply]
@Frietjes: That's the right one, thank you! -- Dsimic (talk) 21:06, 19 November 2013 (UTC)[reply]

MediaWiki:Toc

[edit]

Why is MediaWiki:Toc still invoked if it has been deleted? —GoldRingChip 12:31, 27 August 2019 (UTC)[reply]

@GoldRingChip: Because it works (output is “Contents”). MediaWiki namespace messages need not to exist on Wikipedia to be useable, as long as they exist in MediaWiki itself. —Tacsipacsi (talk) 09:17, 7 September 2019 (UTC)[reply]
Ok, I guess that works. Thank you. —GoldRingChip 18:20, 7 September 2019 (UTC)[reply]

hlist not working in mobile app

[edit]

Please add CSS responsible for making the list horizontal (preferably using TemplateStyles) so that it applies everywhere where the template is used. Currently the Android app shows the TOC vertically on pages like List of Latin phrases (P), which takes up a huge place. Thanks in advance, —Tacsipacsi (talk) 09:29, 7 September 2019 (UTC)[reply]

 Not done feel free to mock this up in the sandbox then reactivate the edit request. — xaosflux Talk 17:20, 7 September 2019 (UTC)[reply]

TOC top missing on mobile

[edit]

For some reason, the template "TOC top" doesn't work on the mobile website version of Wikipedia. They don't appear to be displaying at all (not even an empty box). For reference, the browser I'm using is Safari on my iPhone 7 with iOS 12.3.1 jennasloan (talk) 02:18, 15 August 2020 (UTC)[reply]

@Jennasloan: The table of contents is deliberately hidden in mobile mode on mobile (i.e. when accessing Wikipedia via en.m.wikipedia.org on a small device, not when using the desktop en.wikipedia.org domain or when using the mobile domain on a large device such as a tablet). This applies to the usual, auto-generated TOC as well. I don’t know why is this so, but I don’t think this custom TOC should be unhidden as long as the standard one is hidden. —Tacsipacsi (talk) 10:49, 15 August 2020 (UTC)[reply]
@Tacsipacsi: It's just the fact that it is hidden on mobile makes some pages such as https://en.m.wikipedia.org/wiki/List_of_role-playing_video_games not display its list. jennasloan (talk) 19:24, 15 August 2020 (UTC)[reply]