Loading...
 
Features / Usability

Features / Usability


Re: Autonumbered Table of Contents for Single Pages

posts: 4656 Japan

> Hello,
> I was wondering if there was anything in tikiwiki or any addons or patches floatings around that added numbered table of contents to single wiki pages, much like wikipedia does. I know you could do it using structures, but to be able to just mark headings with '!' and '!!' and then have it autonumber is what I'm looking for.

Coincidentally, while 'working' at my day job, I was staring at a CSS cheatsheet on the wall of my cubicle and noticed a "counter-increment" property, and took a few minutes to investigate. (w3schools to the rescue again). If you use the {maketoc:box} syntax to make the table of contents box, the following addition to your CSS file will produce a numbered TOC list.

Copy to clipboard
table#toc li { list-style: none; } a.toclink:before { content: " " counter(heading ) " "; counter-increment: heading; }


This numbers all items in order regardless of whether they are children of other items or not. The numbering could be limited to the top-level headings by changing "table#toc li" to "li.toclevel-1" in that code. I only tested this in Opera and am assuming it works in all browsers.

More CSS fun — this should be handled in the template, really, but in the meantime — if "index" seems a bit incomplete to you, you can change it to "Page index" by adding this to your stylesheet:

Copy to clipboard
#toctitle h3:before { content: "Page "; }


-- Gary

There are no comments at this time.