[TW5] How to automate Table of Content?

932 views
Skip to first unread message

James

unread,
Aug 15, 2014, 9:20:10 PM8/15/14
to tiddl...@googlegroups.com
Hi All,

I would like to automate my Table of Content, could anyone willing to shed some lights on how doing that?

Thanks.

Matthew DeAbreu

unread,
Aug 16, 2014, 8:51:09 PM8/16/14
to tiddl...@googlegroups.com
Using the table of contents from tiddlywiki.com as a starting point you can use the list widget to generate a list of tiddlers. For example this code below will create a list of all tiddlers tagged with "Game".

<<toc-heading "Games" "
<ol>
<$list filter='[!is[system]tag[Game]]'>
<li><ol><li><$link><$view field='title'/></$link></li></ol></li>
</$list>
</ol>
">>

James

unread,
Aug 17, 2014, 10:58:03 PM8/17/14
to tiddl...@googlegroups.com
Hi Mathew,
Thanks for your response to this.  But the code doesn't seem helping.  It appeared as blank tidder.  I did replace the "Game" tag to my own tag.

Daniel Baird

unread,
Aug 17, 2014, 11:04:58 PM8/17/14
to tiddlywiki

Double check you have the right angle brackets and quotes.  If that doesn't fix it, can you show us what you have?  Like, share your wiki on tiddlyspot.com or something?


--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



--
Daniel Baird
objoke: I had a problem and decided to solve it with threading. Now, have problems. two I

Matthew DeAbreu

unread,
Aug 17, 2014, 11:18:09 PM8/17/14
to tiddl...@googlegroups.com
Make sure you include the macro definition so the full code would look something like this:

\define toc-heading(caption,body)
<$reveal type="nomatch" state=<<qualify "$:/state/toc/$caption$">> text="show">
<$button set=<<qualify "$:/state/toc/$caption$">> setTo="show" class="btn-invisible">{{$:/core/images/right-arrow}} $caption$
</$button>
</$reveal>
<$reveal type="match" state=<<qualify "$:/state/toc/$caption$">> text="show">
<$button set=<<qualify "$:/state/toc/$caption$">> setTo="hide" class="btn-invisible">{{$:/core/images/down-arrow}} $caption$
</$button>
</$reveal>
<$reveal type="match" state=<<qualify "$:/state/toc/$caption$">> text="show" retain="yes" animate="yes">

$body$

</$reveal>
\end

<<toc-heading "Games" "
<ol>
<$list filter='[!is[system]tag[Game]]'>
<li><ol><li><$link><$view field='title'/></$link></li></ol></li>
</$list>
</ol>
">>

Hope this helps

Ken Gray

unread,
Aug 18, 2014, 12:34:36 AM8/18/14
to tiddl...@googlegroups.com
wow this works great.  I made a little tweak to the last part of the code to straighten out the numbers.
I just open up the tiddlywiki site and made a new tiddler.

<<toc-heading "examples" "
<ol>
<$list filter='[!is[system]tag[examples]]'>

   <li><$link><$view field='title'/></$link></li>
</$list>
</ol>

James

unread,
Aug 18, 2014, 1:19:22 AM8/18/14
to tiddl...@googlegroups.com
Hi Matthew,
It works now.  The macro definition was what I missed out.. :)
Thanks

Jon

unread,
Aug 18, 2014, 1:48:54 AM8/18/14
to tiddl...@googlegroups.com
Hi, this is really useful. I'm trying to adjust it to remove the numbered list but I can't get the resulting tiddlers on a separate line (without double spacing). Any ideas?

Thanks, Jon.

Ken Gray

unread,
Aug 18, 2014, 12:14:15 PM8/18/14
to tiddl...@googlegroups.com
this is really awesome.  I was wondering if there was a way of making netsted categories based on tags.  for instance, if a tiddler was tagged as a "Meeting" and had a tag "Scrum" it would go there.  This would have the benefit of making it easier to skim through all the notes and I wouldn't have to maintain the sub-categories because it would build them automatically.

>
Meetings
> Scrum
> Admin
> Support

On Sunday, August 17, 2014 10:18:09 PM UTC-5, Matthew DeAbreu wrote:

Danielo Rodríguez

unread,
Aug 19, 2014, 9:43:21 AM8/19/14
to tiddl...@googlegroups.com
The problem is, how do you determine which tag should be the parent and which should be the child?

Ken Gray

unread,
Aug 19, 2014, 10:16:24 AM8/19/14
to tiddl...@googlegroups.com
could you do it in the order it's coded?  the first being the parent and then the children would just fall into place after that?

 
 
Ken


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/-cLtPJoqG2E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

Danielo Rodríguez

unread,
Aug 19, 2014, 11:39:13 AM8/19/14
to tiddl...@googlegroups.com
What do you mean with:

could you do it in the order it's coded?

Ken Gray

unread,
Aug 19, 2014, 11:51:19 AM8/19/14
to tiddl...@googlegroups.com
in the same what you assign levels in non-ordered lists.  if you have 3 tids with 'parent' tag assigned and each of them have one tag with 'child0', 'child1', 'child2' respectively but the 1st tid has 'child2' AND 'child3' like this.

  • parent
    • child0
      • tid0
    • child1
      • tid1
    • child2
      • tid2
    • child3
      • tid0

Ken Gray

unread,
Aug 19, 2014, 11:52:47 AM8/19/14
to tiddl...@googlegroups.com
the html would look likej this
<li>parent</li><ul><li>child0</li><ul><li>tid0</li></ul><li>child1</li><ul><li>tid1</li></ul><li>child2</li><ul><li>tid2</li></ul><li>child3</li><ul><li>tid0</li>

Danielo Rodríguez

unread,
Aug 20, 2014, 4:21:19 AM8/20/14
to tiddl...@googlegroups.com
As you can see, you described a hierarchy. There is no hierarchy in tags

tag1,tag2,tag3

The only way you can define that should be
tag1, tag1-2,tag1-3

Ken Gray

unread,
Aug 21, 2014, 12:50:29 PM8/21/14
to tiddl...@googlegroups.com
note as of 5.0.15 beta you can use the tableofcontentsmacro to do this....yeah!

Danielo Rodríguez

unread,
Aug 22, 2014, 6:06:41 AM8/22/14
to tiddl...@googlegroups.com
Amazing.

But this is still no useful for my purposes.
It is cool if you have a topic and subtopics, which is nice. But the way I use tiddlywiki I prefer to tag a tiddler with linux and snippets rather than a single tag called linux-snippets.

Does anyone have a clue of how to do what I want?

PMario

unread,
Aug 22, 2014, 8:20:58 AM8/22/14
to tiddl...@googlegroups.com
On Friday, August 22, 2014 12:06:41 PM UTC+2, Danielo Rodríguez wrote:
But this is still no useful for my purposes.
It is cool if you have a topic and subtopics, which is nice. But the way I use tiddlywiki I prefer to tag a tiddler with linux and snippets rather than a single tag called linux-snippets.

What's the problem, if one tiddler is part of 2 lists?
-m

Danielo Rodríguez

unread,
Aug 22, 2014, 9:58:42 AM8/22/14
to tiddl...@googlegroups.com
Let me explain the problem well.

I want a toc like this:

* Linux
 ** Snippets
*** tiddlerA

With the current setup you have to tag snippets as linux, and the third level as snippets. The problem is that there are not only linux snippets but javascript, VBS and so on. What kind of snippet is a snippet tiddler is defined by the other tag. If a tag tiddlerA with linux and snippets i will get

*Linux
**tiddlerA

In fact, I will only get
*tiddlerA

Because Linux is the root tag.

PMario

unread,
Aug 23, 2014, 7:07:59 AM8/23/14
to tiddl...@googlegroups.com
On Friday, August 22, 2014 3:58:42 PM UTC+2, Danielo Rodríguez wrote:
Let me explain the problem well.

I want a toc like this:

* Linux
 ** Snippets
*** tiddlerA

With the current setup you have to tag snippets as linux, and the third level as snippets. The problem is that there are not only linux snippets but javascript, VBS and so on. What kind of snippet is a snippet tiddler is defined by the other tag. If a tag tiddlerA with linux and snippets i will get

Tag the tiddlerA with snippets and linux and you'r done.

* tiddlerA will be shown if you search for "linux" related content
* tiddlerA will be shown if you search for "snippets" ...
* tiddlerA doesn't loose information if you export it and forget to export related tiddlers.. because snippets will be lost in your setting .....

You only need to take care, that you don't get circular relations.

-mario






Danielo Rodríguez

unread,
Aug 23, 2014, 11:56:05 AM8/23/14
to tiddl...@googlegroups.com

Tag the tiddlerA with snippets and linux and you'r done.

* tiddlerA will be shown if you search for "linux" related content
* tiddlerA will be shown if you search for "snippets" ...
* tiddlerA doesn't loose information if you export it and forget to export related tiddlers.. because snippets will be lost in your setting .....

You only need to take care, that you don't get circular relations.

-mario


I don't understand how is your answer related with the toc. I have those tiddlers already tagged that way, and I find them with no problem. The problem is to organice them in a TOC in an hicherachical way. 

PMario

unread,
Aug 24, 2014, 5:11:24 AM8/24/14
to tiddl...@googlegroups.com
On Saturday, August 23, 2014 5:56:05 PM UTC+2, Danielo Rodríguez wrote:
I don't understand how is your answer related with the toc. I have those tiddlers already tagged that way, and I find them with no problem. The problem is to organice them in a TOC in an hicherachical way. 

You are right, my "inbrain list filter" missed some details :))

but here we go: 2 new tocs  ... <<and-toc ..>>, <<and-tag-toc>>   ... (better name suggestions are very welcome :))

\define and-toc(tag,and:"")
<ul>
<$list filter="[tag[$tag$]$and$]">

<li>
<$link>
<$view field="title"/>
</$link>
<$macrocall $name="and-toc" tag=<<currentTiddler>> and="tag[$tag$]$and$" />
</li>
</$list>
</ul>
\end

<<and-toc windows>> ... creates a hierarchical list of tiddlers, where all tags are "and" tags.
eg:
snippets is tagged windows and linux
TiddlerA is tagged linux and snippet
TiddlerB is tagged windows and snippet

This may be usefull as a stand alone macro.
The next step is "and-tag-toc"

\define and-tag-toc(tag,sort:"")
<ul>
<$list filter="[tag[$tag$]$sort$]">

<li>
<$link>
<$view field="title"/>
</$link>
<$macrocall $name="and-toc" tag=<<currentTiddler>>/>
</li>
</$list>
</ul>
\end

<<and-tag-toc  root-tag>>

eg: tiddler windows needs to be tagged root-tag <- use your own tag here
toddler linux is tagged root-tag

<<and-tag-toc  root-tag>>

will create
  • windows
    • snippet
      • TiddlerB
    • TiddlerB
  • linux
    • snippet
      • TiddlerA
    • TiddlerA
IMO that's the best you get, if you want to work with tags only.
If you combine tags and fields, you'd have endless possibilities and complexity :)

IMO This structure makes sense up to 3 levels deep.
With the "expandy collapsy" buttons it may be ok with more levels. ... just neet to try :)

have fun!
mario
PS: If we get the names right, I'll create a pull request



PMario

unread,
Aug 24, 2014, 5:18:10 AM8/24/14
to tiddl...@googlegroups.com
I think the and-tag-toc structure, combined with a "+" button, that creates a new tiddler that inherits all the tags would be very nice :)
-mario

Danielo Rodríguez

unread,
Aug 25, 2014, 4:25:11 AM8/25/14
to tiddl...@googlegroups.com
Your solution seems to be very cool with the limited options that tags provides.

The problem here is the shorting method, the redundant results and that you have to tag every tag with all the possible parent topics related to it.

I think the best approach is to use fields. I never said that I don't want to use fields. What I don't want is to replace tags by fields, but I think they can coexist. Using the tags for searching and fields for shorting.

Maybe you can help me with this, since you have a better mind for this kind of things. 

I was thinking in using your idea of the root-tag, and tag every tiddler with that root tag. Any extra tags are welcome for future search. Then use a list field of subtopics of the root-tag that tiddler belongs to.

TiddlerA
tags: linux,snippets
subtopics:snippets

TiddlerB
tags: linux,snippets,filesystem
subtopics:snippets,filesystem

Then on the list, I don't know how yet, create a subtopic for each subtopic a tiddler has. Mmmm, I feel like I'm missing some key detail that makes this not possible.

PMario

unread,
Aug 25, 2014, 8:16:48 AM8/25/14
to tiddl...@googlegroups.com
I knew, that you don't like, that some tiddlers are listed twice. ... But for me this is a feature ;)

I did play a little bit with the macro. I did create a brainstorming tree. ...

I found out, that after some refactoring one "child" tiddler had many "childs" itself ... So it actually should have been a parent :)
- The thing to do is, just remove its parent tag and you are done. The list is recreated in a new way. ...

- Some tiddlers actually made sense, for me, to be listed twice.

The advantage here is, that you don't need a management UI other than tags. ...

There is a reason, why I wrote:
If you combine tags and fields, you'd have endless possibilities and complexity :)

As you found out  (see your concept) combining fields and tags adds complexity. ..
The relations are simple (for human brains), but to UI to make handling it convenient isn't there out of the box :/
And it adds some more questions. ... where to use fields, where to use tags ... What if a field becomes a tag or vice versa ...

....

If you want to control the structure of the tree, you could use a field named: parent.
Only the field "parent" is used to create the tree.
Every "tree-tiddler" must have only one parent
The root is created using tags.
Tiddler lists are created using tags

I think this concept would be easy to create and manage (by hand). I'm not sure, if the macro code will be easy :)

let's think a little bit.

-mario



Danielo Rodríguez

unread,
Aug 25, 2014, 9:27:03 AM8/25/14
to tiddl...@googlegroups.com
Hello Mario,

Thank you for your advise. 
I think I'm not using your macros correctly. Could you post a working example so I can analyze it closely?
Thank you!

Danielo Rodríguez

unread,
Aug 26, 2014, 6:41:52 AM8/26/14
to tiddl...@googlegroups.com
I have an approach that is very close to be functional.
The problem is that for every combination of tags, I got the same combination in the opposite order. Just with a couple of tiddlers and tags, you will get a very long list.
I don't know how to improve it.

Here it is:

\define my-toc(tag,exclude,hierarchy)
<ul>
<$list filter="[tag[$tag$]tags[]] -$tag$ $exclude$">
<li>
<$view field="title"/>
<$macrocall $name="my-toc" tag=<<currentTiddler>> exclude="$exclude$ -$tag$" hierarchy="$hierarchy$tag[$tag$]"/>
</li>
<$macrocall $name="list-toc", filter="tag[$tag$]$hierarchy$" curr=<<currentTiddler>>/>
</$list>
</ul>
\end

\define list-toc(filter,curr)
<ul>
<$list filter="[$filter$tag[$curr$]]">
<li>$filter$tag[$curr$]  {{!!title}}</li>
</$list>
</ul>
\end

<<my-toc "linux">>
Reply all
Reply to author
Forward
0 new messages