Pass the "output" of one $list filter through another $list filter

I don’t know if the title exactly describes what I’m trying to do.

  • Let me explain better with an example:

Let’s say that with a button I want to select a tiddler that is in the StoryRiver (putting its title in a field of this tiddler/button) And then I want to compare the contents of the field with the titles of the tiddlers in the storyRiver, so that the selected tiddler is highlighted.

Like so:

(I actually don’t really care about this feature, it’s just to give a simple example of the concept I’d like to understand)
Anyway I would proceed this way:
I create the button in the tiddler “Target”

<$button class='tc-btn-invisible'>
<$action-setfield $tiddler="Target" $field="current" $value={{!!title}}/>
{{$:/core/images/close-others-button}}</$button>

Then I edit $:/core/ui/SideBar/Open and add:

\define HighlightCurrent()
<$list filter="[[target]get[current]] +[!match[{{!!title}}]]" variable="ignore">
<$button class='tc-btn-invisible tc-btn-mini'>
{{$:/core/images/right-arrow}}</$button>
</$list>
\end

And finally I place <<HighlightCurrent>> just before where the close buttons are defined (so to ideally get a little arrow before the “x” that closes the tiddler i selected with the “Target” button)


Where I defined HighlightCurrent() I put a filter that unless something is wrong should hide all the “highlight” buttons except the one next to the tiddler which has the same title as the value of the “current” field.

Here the {{!!title}} I believe (this is where I don’t understand) should be the same {{!!title}} which is used by $:/core/ui/SideBar/Open to to derive the links you see in its output from a $list filter: <$list filter="[list<tv-story-list>]" history=<<tv-history-list>> storyview="pop">
So I thought I could use the same {{!!title}} in another filter at the same time.
But I’m not quite sure how that would work (or if it’s even possible to do something like that).

Could someone explain to me how can an action of this type happen (or if it is possible)?

You almost got it right. Except the line shown above should be:

<$list filter="[[Target]get[current]match{!!title}]">

Notes:

  • The target tiddler title should be “Target” (i.e., capitalized), so it matches the name you used for your “ViewToolbar” button tiddler.
  • The filter should compare the value stored in the target tiddler current field with the title of the current tiddler (as set by the containing <$list filter="[list<tv-story-list>]" history=<<tv-history-list>> storyview="pop">). Note that variable="ignore" doesn’t prevent the $list content from being rendered. It simply defines the name of the variable that holds the current list item value. In this particular use-case, it merely prevents the value of <<currentTiddler>> from being modified within the $list content… and it’s not even needed, since there is no reference to either <<ignore>> or <<currentTiddler>> within the $list content.
  • Your syntax for the match filter operand is incorrect. For filter operands:
    • square brackets enclose LITERAL TEXT values
    • curly braces enclose TIDDLER FIELD references
    • angle brackets enclose VARIABLE names
    • all brackets/braces are SINGLE, not doubled
      Thus, when referencing !!title, you should use SINGLE curly braces and OMIT the square brackets; i.e., match{!!title}

-e

1 Like

You are very kind.
And I’m sorry, I thought what I wanted to do was something more arcane, but I should have just studied the syntax better before asking, I now feel like I could have avoided asking the question.
I swear at least that I lost the capital “T” along the way because I changed the name when I posted the topic to make reading clearer. :sweat_smile: The other things, however, I didn’t know, and I thank you for having told me, very helpful