| ||
![]() |
Adding a Menu of the Header tags within a Document | |
|
This explains how to add an automatically updated menu of all the Header tags within a Lenya document. It handles all 6 levels of headers (H1, H2, H3, H4, H5, H6), and only requires changing the XSL and CSS.
This solution depends on CSS for formatting the data; the XML data is never hierarchical. I have not found an easy method to create a hierarchical data structure from flat (non-hierarchical) data using just XSL. This means an H4 directly under an H2 will still be formatted (indented) as an H4, which is probably the desired display. The anchors are named like "h3-7" (tag name + "-" + absolute position) to solves the issues of duplicates and url-encoding the text, but makes the names much less memorable. The tag name and the dash are not necessary; they are remnants of earlier attempts. InstructionsFILE: {pub}/xsl/page2xhtml.xsl Put this line where you want the headers menu: <xsl:apply-templates select="//xhtml:h1|//xhtml:h2|//xhtml:h3|//xhtml:h4|//xhtml:h5|//xhtml:h6" mode="headers"/>
Add these matches: <!-- Headers Menu -->
FILE: {pub}/resources/shared/css/page.css Add this to your CSS (to indent each level): /* Header Menu */
|