Re-do of question about 3 level filter problem + sortan question

Hi everyone

I have been trying to create a system where I have three kinds of tiddlers: sources, topics and notes.

Each note tiddler would have a source field that lists a source [[Free Will (Harris)]], and a pagenumber field, and I would add topics as tags.

Each topic tiddler would be tagged .topic, and would have a corresponding viewtemplate tiddler that a) lists the sources for which there are notes for that topic, and b) under each source, a list of the notes from that source that are tagged with that topic.

Each source tiddler would be tagged .source, and would have a corresponding viewtemplate tiddler that a) lists the topics for which there are notes for that source, and b) under each topic, a list of the notes from that topic for which a literal search of the source field turns up a match for the source tiddler’s title.

I couldn’t get the topic tiddlers to work, even with @Brian_Radspinner 's additional help. So I don’t have a screenshot.

I did get the source tiddlers to work, but they don’t sort the pagenumber fields as ‘sortan’. See screenshot below:

The viewtemplate tiddler text for this is below. Note my attempts to add ‘sortan’ here and there.

\define getTids() [search:source:literal<currentTiddler>]

<$list filter="[<currentTiddler>tag[.source]sort[title]]">

<$list variable="getTags" filter="[subfilter<getTids>tags[]sortan[]sort[pagenumber]]">

<b><$text text=<<getTags>> /></b>
<$list filter="[subfilter<getTids>tag<getTags>sort[pagenumber]sortan[]]">
<details style="margin-left: 1em;">
<summary><$view field="title"/> (<$view field="pagenumber"/>) &nbsp;<$link>*</$link></summary>
<i><$transclude field="text" mode="block"/></i>
</details>
</$list>
</$list>
</$list>

<span>

So my questions are:

  1. How can I get the snippet above to sort the list items correctly by sortan?
  2. How can I ‘flip’ this in the other viewtemplate so that in the topic tiddler ‘Free will’, sources will be listed in alphabetical order and under each source there will be a list of the notes for that source that have ‘Free will’ as a tag, and the list is sorted by the pagenumber field, in a sortan way?

I didn’t look at that thread, but I think I have a working model of what you describe…

Some details differ, but this should serve as proof-of-concept: Biblio-Springer — working on automatic author template

I can’t test, but does sortsub work?:


<$let by-page-nbr="[get[pagenumber]">
...
<$list variable="getTags" filter="[subfilter<getTids>tags[]sortsub:alphanumeric<by-page-nbr>]">
...
<$list filter="[subfilter<getTids>tag<getTags>sortsub:alphanumeric<by-page-nbr>]">
...
</$let>
1 Like

Thanks Springer! I will have a look at this in a day or two. Swamped with work after a long trip to Honduras.

1 Like

Thanks Scott! I will have a look at this tonight or tomorrow for a moment. Swamped with work after a long trip to Honduras.

I did test the above, and this seems to work fine. Download and drag this onto any wiki, import, and open the Sortsub Demo tiddler:

sortsub.json (1.1 KB)

You could also use a \define in place of the <$let>:

\define by-page-nbr() [get[pagenumber]]
1 Like

Thanks Scott! Going to have to call you “Great Scott!” I will work on integrating this with the snippet I included in the OP. Blessings.

Hi everyone

Here are the solutions that worked for me. Learned a lot from @Scott_Sauyet and @Springer ! Thanks to both of you.

For notes on a source, organized by topic:

\define getTids() [search:source:literal<currentTiddler>]

<$list filter="[<currentTiddler>tag[.source]sort[title]]">

<$list variable="getTags" filter="[subfilter<getTids>tags[]sort[title]]">

<b><$text text=<<getTags>> /></b>
<$list filter="[subfilter<getTids>tag<getTags>sort[pagenumber]] +[sortan[pagenumber]]">
<details style="margin-left: 1em;">
<summary><$view field="title"/> (<$view field="pagenumber"/>) &nbsp;<$link>*</$link></summary>
<i><$transclude field="text" mode="block"/></i>
</details>
</$list>
</$list>
</$list>

<span>

For notes on a topic, organized by source:

<$list filter="[<currentTiddler>tag[.topic]sort[title]]" variable=null>

<$let topic={{!!title}}>

<$list filter=" [tag<topic>has[source]get[source]unique[]sort[]]" variable="source">

<details open><summary><b><$view tiddler=<<source>> field="title" /></b> <$link to=<<source>>>*</$link> </summary><span class="indent2">

<$list filter="[tag<topic>source<source>] +[sortan[pagenumber]]">

{{!!title}}, {{!!pagenumber}} <br>

</$list>

</span></details>

</$list>
</$let>

</$list>

To see the results, check out 2-2024 test. I haven’t finished adding the css and plugins yet. And I think there are a couple things I need to change in the new note button. But it is essentially there.

Blessings to all.

2 Likes

FYI I would now use the function, here rather than the deprecated define

\function get.Tids() [search:source:literal<currentTiddler>]
...
<$list variable="getTags" filter="[get.Tids[]tags[]sort[title]]">
  • It avoids the subfilter operator, uses less bytes (OK not many less) and make the filter more readable in my view.
  • I did not have the setup to test this.

:nerd_face:

I may even name the function matching.source[] or something more meaningful than get.tids.

1 Like

Thanks Tones. If I ever decide to use it for more than personal use, I will make the switch. Blessings.