Using kin filter with multiple tags

81 views
Skip to first unread message

Damon Pritchett

unread,
May 9, 2020, 12:27:42 AM5/9/20
to TiddlyWiki
All,

I've been using the following code which encompasses the kin filter to trace tiddler tags. More specifically, I'm using it trace the line of mergers for certain railroads (each railroad is a separate tiddler) such that for any given company I can see the line of successive railroads traced all the way up to the present.

<!-- use kin filter to find succession of tags -->
<$list filter='[all[current]title
<currentTiddler>kin:tags:from[]!is[system]!title[Railroads]!title<currentTiddler>limit[1]]' variable=null>
Successors to ''<
<currentTiddler>>'':
<br>
</$list>
<ul>
  <$list filter="[title
<currentTiddler>kin:tags:from[]!is[system]!title[Railroads]!title<currentTiddler>]"> ->
    <$link><$view field="title"/>
    </$link>
  </$list>
</ul>


It generally works quite beautifully, but I have a very small  number of cases where I have where the railroad was split and merged into two different companies. The above code includes everything, but shows all as a single line of succession. I'm pretty sure that the kin filter was only meant to trace a succession of single tags so I'm wondering if there is something I can do to the code above or I'll have to figure out a way to split tiddlers. Any suggestions will be welcomed.

Thanks,

Damon

TonyM

unread,
May 9, 2020, 4:42:37 AM5/9/20
to TiddlyWiki
Damon,

It is the standard TOC that tends to work the other way, dividing into branches, leaves etc... Can you ask the Question the other way around?

If you can write an independant filter you can actually subtract one from the other such as a filter than runs out all branches, then remove the tiddler in the main line (not railways) the original kin filter exposed, what will be left is the line of tiddlers that were not in the first filter, or you can add them together.

I know this is but a hint, not a solution but the test data is not available. If you could demonstrate it on say a copy of tiddlywiki.com?

Regards
Tony

Damon Pritchett

unread,
May 9, 2020, 2:09:13 PM5/9/20
to TiddlyWiki
Here's an example I created to illustrate.

I have a series of tiddlers named RR#1 through RR#7.  RR#1 will be the base and all others are successive tags from there. I've included some screenshots of the filter at work. If RR#1 is only tagged with RR#2, then I get  what is illustrated in picture1.png. If RR#1 is only tagged with RR#5, then I get what is pictured in picture2.png. If RR#1 is tagged with both RR#2 and RR#5, which is the case I'm trying to fix, I get what's in picture3.png.

I've thought about different ways of breaking the tiddlers up, but I can't get away from one tiddler being tagged with two.

Tony - I'm not sure I followed the hint you were trying to give. Maybe it's because I haven't had enough caffeine this morning.

Thanks,

Damon
Picture3.png
Picture1.png
Picture2.png
Message has been deleted

Damon Pritchett

unread,
May 11, 2020, 7:51:55 PM5/11/20
to TiddlyWiki
Alrighty then. After a bit of trial and error and realizing that there were other considerations when a tiddler has a succession of two tags, but then those two tags have a common single tag and also having to make sure that I didn't break the normal case where only one tag was involved (whew!), I came up with the code below. It does work for all cases that I've come across so far in my TW. I know that it only handles the case when there is a single tag or two tags, but not more than two. It was definitely a learning experience. Now the trick will be to remember those lessons learned.

I would appreciate any feedback if anyone sees a simpler or more generic way of doing it or there is something fundamentally wrong with the way I did it.

<!-- use kin filter to find succession of tags -->



<$list filter="[title
<currentTiddler>tags[]tag[Railroads]count[]compare:number:eq[1]then<currentTiddler>]">
  Successors to ''<
<currentTiddler>>'':
 
<ul>

    <$list filter="[title
<currentTiddler>kin:tags:from[]!is[system]!title[Railroads]!title<currentTiddler>]"> ->
      <$link><$view field="title"/>
      </$link>
    </$list>
 
</ul>

</$list>


<$list filter="[title
<currentTiddler>tags[]tag[Railroads]count[]compare:number:gt[1]then<currentTiddler>]">
  Successors to ''<
<currentTiddler>>'':
  <$list filter="[title
<currentTiddler>tags[]tag[Railroads]first[]]" variable=firsttag>
  <$list filter="[title
<currentTiddler>tags[]tag[Railroads]last[]]" variable=secondtag>
   
<ul>
      <$list filter="[title
<firsttag>kin:tags:from[]!is[system]!title[Railroads]!title<currentTiddler>]"> ->

        <$link><$view field="title"/>
        </$link>
      </$list>
   
</ul>
   
<ul>
      <$list filter="[title
<secondtag>kin:tags:from[]!is[system]!title[Railroads]!title<currentTiddler>]"> ->

        <$link><$view field="title"/>
        </$link>
      </$list>
   
</ul>
  </$list>
  </$list>
</$list>


Reply all
Reply to author
Forward
0 new messages