One more tonight...
It seems that I am unable to use the built-in TOC macro for wiki
content which is generated dynamically from a Class Sheet {{include}}.
I assume this is because the TOC macro is rendered before (or
simultaneously with) the include macro which actually displays the
objects on the page, so as far as the TOC macro knows, there are no
wiki headings on the page (yet) to create an outline from.
Does anyone have any suggestions on how to parse through the final
rendered output of the wiki page to generate a table of contents for
dynamically generated wiki content? If I'm missing something with the
existing macro, that would be great...
What I am looking to do is write some code (preferably in a panel, I
think), which creates a TOC-style index of all the wiki-syntax
headings contained on the fully rendered page, after the content has
been generated from TextArea properties of a set of attached objects
to the page.
I have written custom display code that loops through every object of
a custom class attached to a page and then displays some of that
objects properties in a series of collapsible div's. Each object
contains two TextArea properties - one for WYSIWYG data, and one for
plain text, which would be formatted in wiki syntax. The result is a
list of each objects name with an expandable <div> full of the
wiki-rendered content contained in the TextArea properties. I would
like to generate a TOC which "reads through" that content and comes up
with a list of only the relevant headings under each displayed
"object"
For example, on a page with 3 objects, the custom display code in the
Class Sheet results in this (the wiki syntax appears fully rendered,
obviously):
Object 1 Name - Click to expand
******Hidden until clicked********
==Heading 2==
===Heading 3===
Normal text, etc...
Object 2 Name - Click to expand
******Hidden until clicked********
==Heading 2==
===Heading 3===
Normal text, etc...
Object 3 Name - Click to expand
******Hidden until clicked********
==Heading 2==
===Heading 3===
Normal text, etc...
I would like the TOC to return:
Object 1
Heading 2
Heading 3
Object 2
Heading 2
Heading 3
Object 3
Heading 2
Heading 3
Even when all the div's are initially collapsed/hidden. It would be
ideal if the TOC was clickable and went to the relevant anchor...
I can obviously use getValue() with each TextArea property to return a
string with that objects wiki syntax - but I don't have an easy way to
parse that string to only return the heading levels...
Any guidance would be appreciated.
Thanks,
aaron