[TW5] Solution to generate a tree of parent tiddlers?

461 views
Skip to first unread message

Arkady Grudzinsky

unread,
Nov 21, 2017, 12:32:44 AM11/21/17
to tiddl...@googlegroups.com
Hi, 

Is there a macro similar to the <<toc-selective-expandable>> that would generate an identical tree, except following the tags in the other direction from a given tiddler?

I'd like to create a genealogy TW creating a separate tiddler for each family member and tagging it with two tiddlers for parents.  The <<toc>> macro would produce a tree of descendants for each person.  I'd like to generate a similar tree for ancestors.

I suppose, I can take the <<toc>> macro and replace all "tagging[]" operators for "tags[]" in the list filters and vice versa, but, perhaps, there already is a solution for this.

Thanks.

-- 
Arkady

Stephen Wilson

unread,
Nov 21, 2017, 5:07:06 AM11/21/17
to TiddlyWiki
I'm sure there has been discussion on this before, 
Not helpful I know...


or the more comprehensive tiddlymap http://tiddlymap.org/?

Stephen


On Tuesday, 21 November 2017 05:32:44 UTC, Arkady Grudzinsky wrote:
Hi, 

Is there a macro similar to the <<toc-selective-expandable>> that would generate an identical tree, except following the tags in the other direction from a given tiddler?

I'd like to create a genealogy TW creating a separate tiddler for each family member and tagging it with two tiddlers for parents.  The <<toc>> macro would produce a tree of descendants for each person.  I'd like to generate a similar tree for ancestors.

I suppose, I can take the <<toc>> macro and replace all "tag[]" for "tagging[]" in the list filters and vice versa, but, perhaps, there already is a solution for this.

Thanks.

-- 
Arkady

PMario

unread,
Nov 21, 2017, 7:28:44 AM11/21/17
to TiddlyWiki
Hi,

I did create a <<tocP>> macro. https://wikilabs.github.io/editions/tocP  that works with fields instead of tags.
The default feeld used is: parent

But the name is flexible. see: https://wikilabs.github.io/editions/tocP/#test-tocP-asdf  where it is "asdf"

So it would need a bit of experimenting, but I think it does what you need.

I also did an experiment, named  toc-merge-experiment, that can merge different TOCs of all types.

have fun!
mario



Arkady Grudzinsky

unread,
Nov 21, 2017, 12:42:04 PM11/21/17
to TiddlyWiki


On Tuesday, November 21, 2017 at 2:07:06 AM UTC-8, Stephen Wilson wrote:

I've seen Tidgraph.  It's great.  I'm going to use it.  But it still seems to show the trees "top-down".  I.e., it traverses "branches from the trunk".  And I want to traverse the "roots".  The tree will be still displayed top-down, but the nodes below would show parents of the node above instead of children.


or the more comprehensive tiddlymap http://tiddlymap.org/?


This one is mind-blowing.  Thanks for pointing me to it.  I'll see what it can do.  But, still, not quite answering my question.  I'm looking for something more simple.

-- 
Arkady
 

Arkady Grudzinsky

unread,
Nov 21, 2017, 1:20:38 PM11/21/17
to TiddlyWiki

On Tuesday, November 21, 2017 at 4:28:44 AM UTC-8, PMario wrote:

Hi,

I did create a <<tocP>> macro. https://wikilabs.github.io/editions/tocP  that works with fields instead of tags.
The default feeld used is: parent

Thanks. But your tree still goes in the different direction. You have children below each node, and I want parents below each node:

I
├── Father
│   ├── Paternal Grandfather
│   └── Paternal Grandmother
└── Mother
    ├── Maternal Grandfather
    └── Maternal Grandmother

Whereas the parent-child relationship is still the same: children have two tags designating parents.

I was thinking to modify the <<toc>> macro to and change all tagging[] to tags[] in the filters, but it seems more complicated than that. I need to understand how the <<toc>> macro works. For example, I don’t understand the filter operator toc-link[no], and I don’t see it documented anywhere.

I found this old discussion from 2013. https://groups.google.com/forum/#!topic/tiddlywiki/67N4dBFdXCo but the <$transclude/> widget seems to have changed since then. The current documentation does not mention template or target.

-- 
Arkady

PMario

unread,
Nov 21, 2017, 4:14:25 PM11/21/17
to TiddlyWiki
On Tuesday, November 21, 2017 at 7:20:38 PM UTC+1, Arkady Grudzinsky wrote:
Thanks. But your tree still goes in the different direction. You have children below each node, and I want parents below each node:
I
├── Father
│   ├── Paternal Grandfather
│   └── Paternal Grandmother
└── Mother
    ├── Maternal Grandfather
    └── Maternal Grandmother


What you describe here is 100% tag driven.

I .. tagged root

Mother ... tagged I
Father ... tagged I

Fathers Mother ... tagged Father
Fathers Father ... tagged Father

Mothers Father ... tagged Mother
Mothers Mother ... tagged Mother

TOC config:

<div class="tc-table-of-contents">
<<toc-selective-expandable root>>
</div>


-m

Arkady Grudzinsky

unread,
Nov 21, 2017, 5:45:50 PM11/21/17
to tiddl...@googlegroups.com
On Tuesday, November 21, 2017 13:14, PMario wrote:

> I .. tagged root
>
> Mother ... tagged I
> Father ... tagged I
>
> Fathers Mother ... tagged Father
> Fathers Father ... tagged Father
>
> Mothers Father ... tagged Mother
> Mothers Mother ... tagged Mother
>
> TOC config:
>
> <div class="tc-table-of-contents">
> <<toc-selective-expandable root>>
> </div>

I know I can build an ancestor tree with the existing <<toc>>
macro if I reverse the tagging scheme and use child tiddlers as
tags for parent tiddlers. But if you look at my usecase, I will
still have to traverse the tag tree upwards to build the tree of
descendants. I need both.

--
Arkady

Arkady Grudzinsky

unread,
Nov 21, 2017, 6:47:50 PM11/21/17
to TiddlyWiki

I’m getting what I want with this self-recurring template tiddler “ancestors”:

<ul>
<$list filter="[is[current]tags[]]">
<li>{{!!title}}</li>
{{||ancestors}}
</$list>
</ul>

It shows a list of tags for the current tiddler and then transcludes itself to show a list of tags for each of them, etc. until we run out of the ancestors. Showing ancestor tree for a given tiddler is a matter of adding {{||ancestors}} to that tiddler. Now it’s a matter of styling - adding links, hiding buttons, etc. Hiding would require fiddling with the “state” attribute for each node. Perhaps, I’ll live without it. This is good enough.

I knew it should be simple.

TonyM

unread,
Nov 21, 2017, 11:16:13 PM11/21/17
to TiddlyWiki
Arkady,

That is Quite elegant, I just eliminated the system Prefix, because it got to TableOfContents then $:/tags/SideBar in my case

<ul>
<$list filter="[is[current]tags[]] -[prefix[$:/]]">
<li>{{!!title}}</li>
{{||ancestors}}
</$list>
</ul>

And if I was using this for genealogy and each person was tagged "person" so I did not get it running off on other tags.

If people we tagged male female you could also follow only the the female line.

<ul>
<$list filter="[is[current]tags[]] +tag[person] -[prefix[$:/]]">
<li>{{!!title}}</li>
{{||ancestors}}
</$list>
</ul>

However;
How are you going to use this as a generic solution for the current tiddler what ever it name?

Or do you select the person you want to review their ancestors for?

Regards
Tony

Arkady Grudzinsky

unread,
Nov 22, 2017, 2:01:12 AM11/22/17
to TiddlyWiki

On Tuesday, November 21, 2017 at 8:16:13 PM UTC-8, TonyM wrote:

Arkady,

That is Quite elegant, I just eliminated the system Prefix, because it got to TableOfContents then $:/tags/SideBar in my case

<ul>
<$list filter="[is[current]tags[]] -[prefix[$:/]]">
<li>{{!!title}}</li>
{{||ancestors}}
</$list>
</ul>


And if I was using this for genealogy and each person was tagged "person" so I did not get it running off on other tags.

If people we tagged male female you could also follow only the the female line.

<ul>
<$list filter="[is[current]tags[]] +tag[person] -[prefix[$:/]]">
<li>{{!!title}}</li>
{{||ancestors}}
</$list>
</ul>

Thanks. Once you use +tag[person], you won’t need to use -[prefix[$:/]] or use other exclusion, I suppose, since that filters out all irrelevant tags. In my case, however, I intend to have almost all tiddlers used for people, except, perhaps, the “Home” tiddler used as an introduction. So, I want to keep it simple. I will just make sure that the people tiddlers do not tag anything but other people tiddlers. There will be maximum two tags per tiddler.

However;
How are you going to use this as a generic solution for the current tiddler what ever it name?

I plan to have a similar template for descendants:

<ul>
<$list filter="[is[current]tagging[]]">
<li><$link to=<<currentTiddler>>>{{!!title}}</$link></li>
{{||descendants}}
</$list>
</ul>

To show “Ancestors” and “Descendants” for all tiddlers (except some) by default, I change the $:/core/ui/ViewTemplate/body tiddler adding

<$list filter="[all[current]]-[[Home]]"> 
<!--This filter will return a list of only the current tiddler unless it's the "Home" tiddler.-->
<!--Otherwise it will return nothing, and the template will not be transcluded.-->
<!--Expand exclusion as needed or add <<exclude>> variable defined elsewhere.-->

<$transclude tiddler="AncestorsDescendantsTemplate"/>

</$list>

Then the AncestorsDescendantsTemplate tiddler shall be

<div class="col1">
<!--Use .col1 and .col2 styles for a 2-column layout-->

! Ancestors

{{||ancestors}}

</div>

<div class=col2>

! Descendants

{{||descendants}}

</div>

This should work. I’ve used this for a task management application when I wanted different tiddlers to use different templates.

-- 
Arkady

TonyM

unread,
Nov 22, 2017, 3:00:12 AM11/22/17
to TiddlyWiki
Arkady,

Looks good, thanks for the followup.

Personally I would to anything not to rule out other tags, they can be so useful, if there is any thing that identifies a tiddler as a person, even one of a set like father mother that you can use so your solution is more robust is recommended.

Since all but home is a person at the moment you could tag all STANDARD tiddlers "person" (automated) and remove that from Home. And update your new here/new tiddler to add the person tag for future ones.


I recently created a Footer that goes in the View Template (and A Status Bar), A technique I used was to replicate what is found in the Viewtemplates use of Tags as well.

A Tiddler called 

$:/PSaT/macros/customfooter tagged

$:/tags/ViewTemplate containing;

<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplatefooter]!has[draft.of]]" variable="listItem"><$transclude tiddler=<<listItem>>/></$list>


Then my additional footer macros are simply tagged $:/tags/ViewTemplatefooter

I can now add as many additions to the footer as I want with a simple tag. I actually place buttons at the top and lists at the bottom of the footer, using draggable ordering.

This means I do not modify any system tiddlers like $:/core/ui/ViewTemplate/body
 
Perhaps these are useful?

Regards
Tony

Birthe C

unread,
Nov 22, 2017, 9:02:02 AM11/22/17
to TiddlyWiki
I would love to see a working example of this not ruling out tags. Love your footer idea, Tony, thanks!

Birthe


Arkady Grudzinsky

unread,
Nov 22, 2017, 11:19:03 AM11/22/17
to TiddlyWiki

On Wed, Nov 22, 2017 at 12:00 AM, TonyM <anthony...@gmail.com> wrote:


Personally I would to anything not to rule out other tags, they can be so useful, if there is any thing that identifies a tiddler as a person, even one of a set like father mother that you can use so your solution is more robust is recommended.

Since all but home is a person at the moment you could tag all STANDARD tiddlers "person" (automated) and remove that from Home. And update your new here/new tiddler to add the person tag for future ones.

Since the vast majority of my tiddlers are intended to be “person tiddlers”, it’s easier to have a special mark for “non-person” tiddlers. Also, tags are visible in regular views, and this attribute which serves the purpose of changing the tiddler template, does not need to be exposed to the viewer. So, in my case, I may add a “not-a-person” property to the tiddler, set it to “1” for the few “non-person” tiddlers and add -[has[not-a-person]] to those template filters.

You are right, I may use non-person tiddlers in the future for photos, documents, or places. Those can be identified by the tiddler type or a “place” tag. I’ll deal with them when I decide to add them. I just don’t want to over-complicate this.

I recently created a Footer that goes in the View Template (and A Status Bar), A technique I used was to replicate what is found in the Viewtemplates use of Tags as well.

A Tiddler called 

$:/PSaT/macros/customfooter tagged

$:/tags/ViewTemplate containing;

<$list filter="[all[shadows+tiddlers]tag[$:/tags/ViewTemplatefooter]!has[draft.of]]" variable="listItem"><$transclude tiddler=<<listItem>>/></$list>


Then my additional footer macros are simply tagged $:/tags/ViewTemplatefooter

I can now add as many additions to the footer as I want with a simple tag. I actually place buttons at the top and lists at the bottom of the footer, using draggable ordering.

This means I do not modify any system tiddlers like $:/core/ui/ViewTemplate/body
 
Perhaps these are useful?

Yes, this is very useful. I think, I’ll use your advice. Thanks.

TonyM

unread,
Nov 22, 2017, 5:45:55 PM11/22/17
to TiddlyWiki
Birthe,

I suppose what I am saying is to keep the tagging facility always available. If a tiddler is marked in anyway including an existing  tag, existence of a field, tiddler types or a prefix or suffix in the title, it is possible to include or exclude something in the view or edit template, allowing you to avoid a tag for this puropse. I am looking at ways to use additional fields to store keywords and other "tags" because this leaves the regular tags free to for ad hoc needs or additional hierarchies. Such dedicated keyword sets allows a more targeted search.

Inspired by Arkadys Parent/child macro I actually had trouble sleeping last night (Sydney time) thinking about sophisticated navigation of alternate hierarchies, yes I do have a life, and it includes intellectual pursuits. This has being an obsession of mine for many years because I have a concept for an algorithm which I can bring to life in tiddlywiki.

Good stuff
Tony
Reply all
Reply to author
Forward
0 new messages