Ordered list in table based on field with multiple Tiddler titles

301 views
Skip to first unread message

G

unread,
Feb 9, 2017, 5:29:31 AM2/9/17
to tiddl...@googlegroups.com
Hi

I'm entirely new to Tiddly and am trying to achieve the following. 

I have Tiddlers that contain custom fields that indicate relationships to other Tiddlers (much like the title field) such as  "related_to" and "associated_with". The value of these fields are titles of other Tiddlers the relationship points to. Tiddler 1 for example has a relates_to field with [[Tiddler 2]] [[Tiddler 3]] [[Tiddler 4]] as value. 

What I'd like to do is to create a table in the text of Tiddler 1 with a row for each of the relationship fields (replacing the underscore with a space) with in a cell an ordered list of all the Tiddler titles as links like the following example:


If possible I'd like to have another table in the text of e.g. Tiddler 4 that does this the other way around since Tiddler 1 is the target


In case a table is not feasible, an unordered list like the following one is just as well:

  • Tiddler 1 relates to Tiddler 2
  • Tiddler 1 relates to Tiddler 3
  • Tiddler 1 relates to Tiddler 4
  • Tiddler 1 associated with Tiddler 5
  • Tiddler 1 associated with Tiddler 6
Or something like

Tiddler 1 relates to Tiddler 2, Tiddler 4, Tiddler 4
Tiddler 1 associated with Tiddler 5, Tiddler 6

I tried the following code from the forum:

<$list filter="[!is[system]]">

<$set name="myVariable" filter="[search:relates_to<currentTiddler>]" value={{!!title}} emptyValue="">
<$link><$text text=<<myVariable>>/></$link>
</$set>

</$list>

But in case a non system Tiddler doesn't have a relates_to field and I adapt the 3rd line to {{!!title}} relates to <$link><$text text=<<myVariable>>/></$link> then I get unwanted rows.

Hope this explanation is a bit clear.

Thank you in advance,
Geoffrey

PMario

unread,
Feb 9, 2017, 10:06:51 AM2/9/17
to TiddlyWiki
Hi Geoffrey,

I did build a field based TOC implementation [1] lately and I think it can be used / modified in a way, that would fit your needs.

The approach is a bit different, than your plan. The default behaviour is like this:

It all starts with a "root" and default field called: "parent" so:

tid-1 has a field named: parent with the value: root  ... which will be level 1

tid-2 has a field parent:tid-1 ... level 2
tid-3 parent:tid-1 ... level 2   ...... and so on

It creates something like:

tid-1
    tid-2
    tid-3


So if you need an other level 1, you just create  tid-X  with a parent:root  and it will be automatically added to the above list.

So the whole list generation is dynamic.

To translate this to your usecase, just replace: parent with related_to   or associated_with ... which for me is basically the same thing.

The plugin also has some "magic UI buttons" that let you easily create new tiddlers, that already contain the needed field:value pairs. Which makes creating the structure much more fun!

At the moment, the macros only create TOC-typed lists. But it would be possible to make it more flexible and configurable. or have a new version, that creates tables instead of nested lists. ....

have fun!
mario

[1] https://groups.google.com/forum/#!topic/tiddlywiki/uixJtgcmqQg
[2] TW plugin edition: https://wikilabs.github.io/editions/tocP/

G

unread,
Feb 9, 2017, 12:04:39 PM2/9/17
to TiddlyWiki
Hi Mario

Your plugin might be very useful for me since I will try to create Tiddlers for phases belonging to a parent project. The root will then be the parent project and the subsequent phases each having a lists of tasks to complete.

I'm not sure however if it can help me with my original issue whereby I really need all the related Tiddler titles in custom fields. These are used in conjunction with the Magic Edge-Types from TiddlyMaps that allows me to show the all Tiddlers as nodes and the relationship custom fields are used to create the edges.

This gives me for example the following possibility


So my goal is to iterate in the Tiddler text field of T1 over each relationship custom field one by one and to display the Source and Target of the relationship along with the type of the relationship.


Each of the other nodes next to Tiddler 1 on their turn have custom relationship fields to other Tiddlers.


I hope this helps to clarify my case a bit more. If not, do not hesitate to let me know and I'll elaborate on it.


Best regards,

Geoffrey

PMario

unread,
Feb 9, 2017, 12:58:16 PM2/9/17
to TiddlyWiki
On Thursday, February 9, 2017 at 6:04:39 PM UTC+1, G wrote:
I'm not sure however if it can help me with my original issue whereby I really need all the related Tiddler titles in custom fields. These are used in conjunction with the Magic Edge-Types from TiddlyMaps that allows me to show the all Tiddlers as nodes and the relationship custom fields are used to create the edges.

You are referring to this: http://tiddlymap.org/#Magic%20Edge-Type%20Namespaces - right?
and you use the "tw-list" mechanism?

If so. You are right. My proposed mechanism doesn't work there. .. I'll need to think a little bit about it.

May be there is a "tocL" or tocList macro possible. I'm not sure, if it's possible to create a performant recursion, with the information provided per tiddler. ... I'll need to think about it.

have fun!
mario

G

unread,
Feb 10, 2017, 8:22:13 AM2/10/17
to TiddlyWiki
Hi Mario

That's indeed what I use. Your remark with regards to the recursion having a performance drawback got me thinking.

I have finally accomplished what I was looking for. What I'm in the end am trying to accomplish is to see if we can use TiddlyWiki as a way to gather information from different sources and structure them in a wiki.

What I did was add a pre parsing step to the workflow I use to import Tiddlers using a JSON file. This new step generates the desired table in WikiText format that is then added to the JSON file with the Tiddlers in. After the import the table is displayed with links to the specific Tiddlers.

A brainstorm on achieving the tocList macro can perhaps still be useful to the community since default list field uses titles of multiple Tiddlers and the Magic Edge-Type Namespace from TiddlyMap supports it as well.

Thanks for all the help.

Best regards,
Geoffrey

Tobias Beer

unread,
Feb 10, 2017, 4:33:14 PM2/10/17
to TiddlyWiki
Hi G,

This answer should be interesting to you.


Also, if you are already looking at Tiddler 4, there is no need to mention the title of Tiddler 4 in the table x times.

All you need is a definition list of your relations and the related titles, e.g.:

relates to
   - Foo
   - Bar
   - Baz

Best wishes,

Tobias.

G

unread,
Feb 13, 2017, 9:30:58 AM2/13/17
to TiddlyWiki
Hi Tobias

I've seen your xlist before, but didn't make the connection. This is exactly what I needed!

The table I wished to have is entirely constructed for all outgoing relationships and all incoming relationships. For those interested, I used the following approach

\define getRelatesToRelationship() [list[$(currentTiddler)$!!relates_to]]
\define getAssociatedWithRelationship() [list[$(currentTiddler)$!!associated_with]] 

<$list filter="[all[current]has[relates_to]] [all[current]has[associated_with]]">
<table>
  <thead>
    <tr>
      <td>Source</td>
      <td>Relationship</td>
      <td>Target</td>
    </tr>
  </thead>
    <$list filter="[all[current]has[relates_to]]">
    <tr>
      <td><$link>{{!!title}}</$link></td>
      <td>relates to</td>
      <td>
        <ul>
          <$list filter=<<getRelatesToRelationship>>>
            <li><$link><$view field="title"/></$link></li>
          </$list>
        </ul>
      </td>
    </tr>
    </$list>
    <$list filter="[all[current]has[associated_with]]">
    <tr>
      <td><$link>{{!!title}}</$link></td>
      <td>is associated with</td>
      <td>
        <ul>
          <$list filter=<<getAssociatedWithRelationship>>>
            <li><$link><$view field="title"/></$link></li>
          </$list>
        </ul>
      </td>
    </tr>
    </$list>
</table>
</$list>

<$list filter="[all[current]listed[relates_to]limit[1]] [all[current]listed[associated_with]limit[1]]" variable="none">
<table>
  <thead>
    <tr>
      <td>Source</td>
      <td>Relationship</td>
      <td>Target</td>
    </tr>
  </thead>
    <$list filter="[all[current]listed[relates_to]limit[1]]" variable="none">
    <tr>
      <td><$link>{{!!title}}</$link></td>
      <td>is related from</td>
      <td>
        <ul>
          <$list filter="[all[current]listed[related_to]sort[title]]">
            <li><$link><$view field="title"/></$link></li>
          </$list>
        </ul>
      </td>
    </tr>
    </$list>
    <$list filter="[all[current]listed[associated_with]limit[1]]" variable="none">
    <tr>
      <td><$link>{{!!title}}</$link></td>
      <td>is associated_from from</td>
      <td>
        <ul>
          <$list filter="[all[current]listed[is associated with]sort[title]]">
            <li><$link><$view field="title"/></$link></li>
          </$list>
        </ul>
      </td>
    </tr>
    </$list>
</table>
</$list>

If you have any tips for getting started, do let me know, because this helped a lot 😊

Best regards,
Geoffrey

Pit.W.

unread,
Apr 24, 2017, 1:00:14 PM4/24/17
to tiddl...@googlegroups.com

Hello Geoffry,

your hint concerning "phases ... belonging to a project" is forward-leading. That had not occured to me. Another step to the "MS-Project-Killer"

Thanks for sharing your thoughts,

Pit
--
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 https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/546fcf06-8810-4c33-8644-7e5016ff4ee8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Reply all
Reply to author
Forward
0 new messages