SID-00823: How to Alphabetize TOC
| Status: |
Answered |
TWiki version: |
|
Perl version: |
|
| Category: |
CategoryRendering |
Server OS: |
|
Last update: |
15 years ago |
Hi,
Is there a way to alphabetize the TOC?
I found a link that show how to alphabetize the TOPICS and that seems to work, but I was just curious if you can do it by Topics?
Like at the top of my Twiki Pages, I will do the %TOC% and that will show the individual topics, yet that are not in alphabetical order.
%TOC%
%TOPICLIST{" * [[%INCLUDINGWEB%.$name][$name]]"}%
This shows my TOC at the top and then under that is a complete alphabetizeation of all the things, but... I was just curious how to get the TOC in alphabetical order?
Thanks,
Brian
--
BrianTinsley - 2010-05-03
Discussion and Answer
Sorting a TOC is not directly supported. I think it is an unusual case. What is your use case?
As a workaround you can do a
multiple="on" type="regex" search to create a table of content via a %SEARCH instead of a %TOC.
--
PeterThoeny - 2010-05-03
Let's try that out with some headings in this page:
A Heading
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Z Heading
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
G Heading
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
M Heading
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
TOC With SEARCH, CALC
This gets a little tricky because we need to build an list of headings in a search, remember that in a
SpreadSheetPlugin variable, then manipulate that list to sort it and to build the proper anchor link. We are using some spreadsheet magic with $LISTMAP(), $TRANSLATE() and $SUBSTITUTE() to mimic building the anchor name from a heading string. This is not perfect, so some TOC links to headings might not work.
View the
raw text to see the source.
Details at
VarSEARCH,
FormattedSearch,
RegularExpression,
SpreadSheetPlugin
--
PeterThoeny - 2010-05-03
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.