Tinderbox Forum

Recursive list of links

I would like to produce a series of unordered lists representing the data from a container with agents.

Data looks like this:

Tags (container)
    tagA (agent)
        note 1
        note 2
    tagB (agent)
        note 1
        note 3
    tagC (agent)
        note 3

I have tried to amend @mwra 's useful code from the aTBref file for generating the sitemap. Here’s what I ended up with (this Template note is called “AllTagger” and it is calling itself):

^if($ChildCount & $HTMLExportChildren)^<ul>^descendants("AllTagger")^</ul>^endIf^</li>

I had to remove the !IsAlias from the if condition to collect the notes from the agent. I also had to change children to descendants to pick up the notes collected by the agent.

So, the export is returning all of the notes that I want when the above template is applied to the Tags container note at the top of the tree.

However, it’s not returning them in a hierarchal form. The Tags container appears as an item at the top of the list, then indented one level come all the other notes:

* Tags
    * tagA
    * note1
    * note2
    * tagB
    * note1
    * note3
    * tagC
    * note3

How can I make the notes indent one level in the hierarchy with this recursive template?

children would enumerate the immediate children, which is (I think) what you want.

If the “AllTagger” itself incorporates itself

^if($ChildCount(original) & $HTMLExportChildren(original)) ^<ul>^children("AllTagger")^</ul>^endIf^</li>

then you’ll export a new, nested unordered list for each generation.

No, unfortunately that code gets me this:


In other words, it doesn’t also go into the next level of hierarchy to grab the children of tagA, tagB, and tagC.

However, when I changed it to this, it did work as expected:


I guess I had set the agents to not export children to avoid double exporting notes. Or maybe this is an automatic setting for agents? Either way, thanks for the guidance here.