2022.2

Table Of Contents
Note: Scriptscanonlyhavethesamenamewhentheyarenotinthesamefolder.
4. Writethescript.Ifyouarenotfamiliarwithscripting,see"Writingyourownscripts"onpage808.
Note: Post Pagination ScriptsrunonlywhenaPrintsectionispreviewedoroutputted.
ToverifytheresultsofPostPaginationScriptsonacertainMaster Page,previewthePrintsec-
tiontowhichthatMasterPageisapplied.
CreatingaTableOfContents
Thistopicexplainshowtocreateamulti-page,cross-sectionTableOfContents(TOC)usingaPost
PaginationScript.
ForinformationaboutPostPaginationScriptsingeneral,see"PostPaginationScripts"onpage850.
Thebasicsofscript-writingintheDesignerareexplainedinthefollowingtopic:"Writingyourown
scripts"onpage808.
Step 1: Opening a Print template
CreateoropenaPrinttemplate.
MakesuretouseHTMLheadingslevel1andlevel2(<h1>and<h2>)inyourPrintsections,ifyouwant
tousethescriptsamplethatisgiveninStep3.Thisscriptcollectsthetextandpagenumbersofthese
headingsandputsthemintheTOC.
ToquicklychangeaparagraphintoaHeading,placethecursorinsideofit,orselecttheparagraph
(see:"Selectinganelement"onpage570).Thenselecttheappropriateelement,eitherontheFormat
menu,orfromthe'Elementtype'drop-downonthetoolbar.
Ofcourse,youcouldjustaswellcreateatableofcontentsusingotherheadinglevels,orevenotherele-
ments.Inthatcaseyou'llhavetoadjustthescriptaccordingly.
Step 2: Creating a placeholder for the TOC
CreateoneextraPrintsectiontoputtheTableOfContentsin.
Insidetheextrasection,insertanArticleelement(see"Insertinganelement"onpage569).
GivetheelementanID,forexample:toc-content.ThiselementistheplaceholderfortheTOC.
Step 3: Inserting the Post Pagination script
InsertaPostPaginationscript(see"AddingaPostPaginationScript"onthepreviouspage).
Double-clickonthenewscripttoopenit.
SetitsselectortotheIDthatyouspecifiedinStep2,precededbya#,forexample:#toc-content.
Pastethefollowingcodeinthescripteditor:
Page 852