On Monday, May 4, 2015 at 7:12:32 AM UTC-7, Matthew Petty wrote:
>
> I've been searching around and trying various old options, but I can't 
> seem to find exactly what I need, so I'm asking directly. Is there a way to 
> have an expandable tree generated, like the TOC example here: 
> http://tiddlywiki.com/#TableOfContents
>
> But I don't want to have to specify which tiddlers should appear in the 
> TOC. I would like to do it by specifying a root tiddler, and then all the 
> child tiddlers would have a field called "parent", which would point to the 
> root tiddler.
>
> In this way, you could have multiple levels, with each pointing to the 
> relevant parent:
>
> * Root (no parent)
>     * Level 1 (parent="Root")
>         * Level 2 (parent="Level 1")
>
> Then later on I could add another tiddler "New", give it the parent 
> "Root", and the TOC would appear like this:
> * Root (no parent)
>     * Level 1 (parent="Root")
>         * Level 2 (parent="Level 1")
>     * New (parent="Root")
>
> So the macro call would be:
>
> <<TOCtree root="Root">>
>
> The advantage of using the field like that is that I would only need to 
> add the field to a tiddler, and the TOC would update.
> Also, by specifying the root of the tree in the macro call, I could just 
> show branches instead of the whole thing.
> Is this possible? Has it been done?
>

The functionality you describe is almost *exactly* what the core TOC macro 
provides... except that it uses *tags* instead of a *custom field* 
("parent") to define the hierarchy.  Simply tag a tiddler with the title of 
it's parent.  Provide the "root tag" in the <<toc>> macro, and all the rest 
happens auto-magically: starting from the root tag, it lists all tiddlers 
with that tag, and then recursively lists all tiddlers tagged with those 
tiddler titles, etc.

One advantage of using tags instead of a "parent" field is that you can 
have the same tiddler appear in more than one part of your tree, simply by 
tagging it with multiple tiddler names.  This can be useful for adding 
"reference" pages to various sections (e.g., a list of definitions could be 
tagged "Appendix", but also tagged with individual pages where those 
definitions are used, so that they are available for quick reference 
directly from those pages.

Note: the default core <<toc>> macro generates a fully-expanded tree.  The 
core also provides some variants of <<toc>>... to show a closed tree with 
"click to expand", use <<toc-selective-expandable>>.  Also, to get the same 
styles as the sidebar, wrap the macro with a "tc-table-of-contents" CSS 
class, like this:

@@.tc-table-of-contents <<toc-selective-expandable RootTagHere>>@@

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
   http://TiddlyTools.github.com/fundraising.html#MakeADonation

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/080bf7c7-5dec-49b3-a2e3-8ddf4b4955d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to