Strange List Issue with list-links

70 views
Skip to first unread message

Reinhard Engel

unread,
Jan 18, 2022, 3:54:41 AM1/18/22
to TiddlyWiki
In the attached TiddlyWiki I describe a strange issue with 'list-links'. I don't know if this is an error or I just missed something.
strange_list_error.html

Eric Shulman

unread,
Jan 18, 2022, 7:12:35 AM1/18/22
to TiddlyWiki
Here's your code that doesn't work:
```
\define listtitle() ''Books by $(currentTiddler)$''
\define filter() "[tag[$(currentTiddler)$]tag[Book]]"

<$list filter=<<filter>> variable="_"> <<listtitle> </$list>

<<list-links filter:"[tag[$(currentTiddler)$]tag[Book]]">>
```

Here's what's wrong:
1) There is a missing `>` at the end of `<<listtitle>`.  As a result, the macro call isn't closed until the final `>>` at the end of the code.  All the content between the error and the ending `>>` are treated as parameters to the macro.
2) The `$(variablename)$` syntax is only parsed when it occurs within a macro.  Thus, `"[tag[$(currentTiddler)$]tag[Book]"` is actually looking for a literal tag value of `$(currentTiddler)$`.
3) You don't need the double-quotes around the content of `\define filter() "..."`.
4) If there are multiple Book tiddlers for the current Author, your `<$list>` widget (with the correction for the missing `>`) would display the `<<listtitle>>` text multiple times, once for each matching Book tiddler.
5) You don't actually need to use `$(currentTiddler)$` anywhere in the above code... `<<currentTiddler>>` (or `<currentTiddler>` within a filter) is sufficient.  In fact, you don't need to use any macros at all.

Here's some corrected/simplified code:
```
<$list filter="[tag<currentTiddler>tag[Book]limit[1]]" variable="_">''Books by <<currentTiddler>>''</$list>

<<list-links filter:"[tag<currentTiddler>tag[Book]]">>
```

Notes:
1) The filter for the heading uses `limit[1]` so that the heading text is only displayed once, regardless of how many matching Book tiddlers are found.

enjoy,
-e

Reinhard Engel

unread,
Jan 18, 2022, 9:18:14 AM1/18/22
to TiddlyWiki
@Eric Shulman

Thank you for enlightening me!

at 1) A case of blindness: I missed the missing `>` at the end of `<<listtitle>, because the list title was always  displayed.

at 2) I defined the macros, because I hope that some day I can use transclusions with parameters and pass in 'Book', 'Article', 'Video', etc. But even then, as your code shows, I probably wouldn't need them.

at 3) A misunderstanding: These are not double quotes, but two double single quotes to make the list title bold.

at 4) A case of laziness: I only tested for zero and one cases, not for more than one.

at 5) A case of ignorance: I'm not yet familiar with the finer details of the use of angle brackets within text and filters. Thanks for the clarification.

Your corrected /simpilified code works as desired!

Thanks again,
-Reinhard
Reply all
Reply to author
Forward
0 new messages