Table of Content made from field not from tag

Hello Experts,

I amusing the to-selective-expandable often in my wiki. So far so good.
Now I am asking myself if it is possible to generate a table of content not from tags like

<<toc-selective-expandable 'TableOfContents'>>

instead using a field (or more than one) like

<<toc-selective-expandable field=Name1 and field=Name2>>

I found a lot of examples using tags, but nothing with fields.

If not possible, ok, than I have to transfer a lot of fields to tags :man_shrugging:

Thx in advance for your answers
Stefan

1 Like

It looks like your filter code is missing because of forum-specific formatting.
If you want to put code in, just enclose in single back-ticks so it looks like this or triple back-ticks so it looks

like this (Now I can type ` single back-tick!)

At any rate, I think this thread is what you want. Short answer is “no” (you can’t use the built-in TOC macro “out of the box” with an arbitrary filter), BUT you can use “except” parameter… or you could duplicate the TOC macro with something that works with field-based info, [edit: which @pmario has already done (see @etardiff post below)]

-Springer

1 Like

Also! If you decide the TOC convenience wins out, and you need to add a tag to a whole bunch of tiddlers with a certain field value (and then again for another field value, etc.), I highly recommend the Commander plugin from @Mohammad

No need to remove the field value (unless you’re worried about keeping your solution “sleek”); it still might prove helpful down the road, since fields do offer a kind of precision (especially within view templates and complex searches) that’s harder to achieve with tags.

You may be interested in @pmario’s tocP plugin, which provides an alternate set of ToC macros for use with fields.

(Nearly deleted this when I saw @pmario’s name in the thread @Springer linked, but on further scanning, I don’t think it did come up. My apologies if this is redundant!)

2 Likes

Indeed, I had not seen that tocP plugin, so I’m very grateful that you pointed it out in this thread!

Thanks @pmario – this is a great tool!

1 Like

With a lot of help from @pmario and @EricShulman is here the solution:

ToC: TableOfContents
tags: $:/tags/SideBar
title: TableOfContents
type: text/vnd.tiddlywiki

<div class="tc-table-of-contents">
<$transclude $variable="toc-selective-expandable" tag={{{ [<tv-history-list>get[current-tiddler]get[ToC]] }}}/>
</div>

The field named “ToC” is the trigger for the tag to be used as selector of the table of contents.

Thank you so much all helping people here.

Stefan

2 Likes