Pivoting multiple filters into one table in TiddlyTables

76 views
Skip to first unread message

Soren Bjornstad

unread,
Mar 22, 2020, 10:12:53 AM3/22/20
to TiddlyWiki
Hi everyone,

I'm working on a custom reference explorer for my wiki using TiddlyTables. It inspects links, tags, fields, and so on to generate a rich display of connected tiddlers categorized by their type.

I'd like to include a column that identifies the type of link (e.g., hardlinked, backlinked, listed in a field, tagged, etc.). I don't want nested tables -- they should all be listed in the same table, but one of the columns categorizes the elements by link type. TiddlyTables doesn't appear to have any built-in features to accomplish this kind of "pivot" operation.

Here's what I managed to do last night. I first created a filter that included all the types of links for certain tags:

[<storyTiddler>backlinks[]] [<storyTiddler>links[]] [<storyTiddler>tagging[]] +[!tag[Source]!tag[Publication]!tag[Place]!tag[Meta]!tag[PAO]sort[]]

I then added a pseudo-field called "linktype" to my table. This field doesn't actually exist on any tiddlers (and it can't, because it's not a property of the tiddler itself but depends on the relationship between it and the story tiddler at the time the table is rendered). I then created a custom template for this field, which looks something like this:

<td>
 <$list filter="[
<currentRecord>] -[<storyTiddler>links[]] +[else[Link]] -[<storyTiddler>backlinks[]] +[else[Backlink]] -[<storyTiddler>tagging[]] +[else[Tagged]]">
 <
<currentTiddler>>
 </$list>
</td>

So basically, all of the relevant types of links are pulled together in one list, and then when the empty "field" linktype is rendered for each record, the display template repeatedly attempts to make the list containing the single element currentRecord empty by subtracting the lists of different link types, and outputs the link type as a string when it succeeds (note that something might be more than one type, in which case the first type listed takes precedence, links > backlinks > tag).

The main problem with this approach is that you cannot sort by the link type field (because the field has no content, so all elements have the same sort key). I'd like to allow the user to filter/sort based on the link type. Ideally, I would also like to list multiple types if the tiddler is related in multiple ways (e.g., tagged and backlinked). I could do this in theory with the current method, but by the time I'm done adding link types, the filter would be a mile long with all the combinations.

Are there any TiddlyTables features or other approaches I'm missing here that might let me address these issues without overcomplicating things? Thanks in advance for any suggestions!

TonyM

unread,
Mar 22, 2020, 5:32:07 PM3/22/20
to TiddlyWiki
Sorren,

I have seen TiddlyTables develop as I have built my own parallel solutions, So I do not have an answer for it, but I have a deep understand of the methods.

I am currently building an equivalent to tiddly tables for a specific tiddlywiki application. I have being thinking along the same lines as you are and looking at what I am calling virtual fields
  • I have a tiddler that defines every field, and the field definition specifies a field-type which is separately defined (and often reused)
  • Within each field-type there is wikitext for the field when in edit view modes etc...
  • I have a macro `<<field fieldname>>` that is used in every cell of my table.
  • Now I plan to introduce calculated or virtual fields so they can be used in an interactive table (This would be like your link output)
  • In my interactive table it is easy to set the sort order to an existing field, but as you say what if it is a calculated value?
I have a simple answer, although may develop a more sophisticated one later. Tell me if you have trouble following my suggestion
  •  inside a button, Using the same filters you use to generate your table,
  • Generate the sort key and/or the result of your link analysis and save it in each tiddler (as field(s)) using actionsetfield
  • Then the tiddlers can be sorted on the sort key, in the table, after a click of a button to refresh this field.
  • Basically you transform the virtual field into a real field so the table can sort it.
  • If you do not want to store the result of your link analysis in each tiddler, you could save it in a data tiddler using the tiddler name as a key. And access this via a virtual field in  the table
In closing
  • Capturing the result of your link "analysis" in each tiddler could have great design outcomes, 
    • The link analysis would be available outside the table
    • You could have a mechanism to update the link analysis for a specific tiddler on save
    • Such that after the initial build it maintains itself.
I hope this helps
Tony
Reply all
Reply to author
Forward
0 new messages