Tags:
create new tag
view all tags

SID-00823: How to Alphabetize TOC

Status: Answered 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.

Table of contents:

View the raw text to see the source.

Details at VarSEARCH, FormattedSearch, RegularExpression, SpreadSheetPlugin

-- PeterThoeny - 2010-05-03

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title How to Alphabetize TOC
SupportCategory CategoryRendering
TWiki version

Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2010-05-03 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.