Template talk:TOC

From GodWiki
Jump to: navigation, search

Copied this template from wikipedia to do some testing. Feel free to ignore it unless I wind up bothering anyone ;)

--The Smurf (talk) 05:40, 15 March 2020 (UTC)

Repurposing and plans

It isn't clear exactly what purpose The Smurf had in mind for his experiment with {{TOC}}, but since it's not been developed or put to use, I'm re-purposing this template to solve the no-TOC-on-mobile problem. (The Smurf, this isn't meant to discourage you from working on this if you intend to; you'll find your last edit here and you're welcome to continue in a sandbox page, e.g. User: The Smurf/Sandbox.)

First draft of this is very rudimentary, and only support a single header depth. I plan to introduce sub-headings before long, once I'm confident there's a sensible way to do that. Since the other wiki uses Lua or extensions for all the non-standard tables of contents, and isn't trying to solve the same problem, I haven't yet found any elegant solutions that will directly translate. Input on how to rationally implement header sublevels welcome! -- Djonni (talk) 07:54, 25 August 2020 (UTC)

Two basic approaches for sub-headings that I can see, and the more I think about it the more one seems the right way, but I want a sanity check from other users, please 😊
Approach one: |section1depth=n, |section2depth=n, etc. (Exact names of these parameters TBD.) Simply put, if you want the section named {{{2}}}to appear as 1.1, a sub-section of section {{{1}}}, you would set |section2depth=2. This is the most programatically elegant approach (because {{loop|{{{section2depth|1}}}|#}}), but I just don't think it's intuitive for new users.
Approach two: Support named parameters |1.1=..|1.10=, |2.1=..|2.10=, etc, and I suppose |1.1.1=, etc... this is a bit tedious to code but in a good text editor it's not too bad. It also strikes me as the most intuitively obvious and sensible way to go, but, again, want a sanity check. Especially as this approach will lead the template code to be pretty huge and a challenge for future editors to work with without a good feature-rich external code editor at hand.
Any good ideas I haven't thought of are welcome too! -- Djonni (talk) 08:30, 25 August 2020 (UTC)