You are here:   » Home » Documentation » Details » How-To » TOC-Lists » Home

Anchor list to all titles within a document

Author: Dr. F. Hoffmann, Dirk Nordmann, 2003/07/14

Titles of a longer document shall be listed alltogether at the beginning of the page in form of an anchor list to allow a direct jump in the document hierarchy.

Solution: At the beginning of the page, e.g. in template bodyContent_Description, a list-iteration is added that is displayed depending on a DC.Type attribute value (e.g. 'ArticleTOC').

<dtml-if "getObjProperty('attr_dc_type',REQUEST)=='ArticleTOC'">
 <dtml-in "filteredChildNodes(REQUEST,['ZMSTextarea'])">
  <dtml-if "getFormat(REQUEST) in ['headline_1','headline_2','headline_3']">
   <dtml-in "_.range(_.int(getFormat(REQUEST)[-1])*2)"> </dtml-in>
   <a href="#<dtml-var id>"><dtml-var "getText(REQUEST)"></a><br>
  </dtml-if>
 </dtml-in>
</dtml-if>