Add/Remove Specific Text String From Tiddlers

So, I have a custom wiki and I’m working on a Checkbox Tiddler Selector I am trying to essentially create a filter of all checked tiddlers, currently I am doing this with tags however this method creates some issues, as the system is used to export/preview/send tiddlers the tag modifies the tiddler and is essentially orphaned when sent to a new wiki or an existing one.

What I’m wanting is to create a single filter tiddler, then when a tiddler is checked the filter tiddler has a new snippet of text added for example

Tiddler 1 [Checked]
Tiddler 2 [Checked]
Tiddler 3 [Unchecked]

Filter Tiddler:
[[Tiddler 1]] [[Tiddler 2]]

If Tiddler 1 is Unchecked I want the filter tiddler to then appear with only [[Tiddler 2]]. Any ideas for this dynamic filter/selector?

It’s not clear to me what you mean by a “checked tiddler” or “when a tiddler is checked.”

Here is one approach that makes a guess at that:

CheckboxTiddlerSelector.json (1.3 KB)

title: Filter Tiddler

[[Tiddler 1]] [[Tiddler 2]]
title: Check Handlers

\define checkActions() <$action-listops $tiddler="Filter Tiddler" $field="text" $subfilter={{{ [<currentTiddler>format:titlelist[]] }}}/>
\define uncheckActions() <$action-listops $tiddler="Filter Tiddler" $field="text" $subfilter={{{ [<currentTiddler>format:titlelist[]addprefix[-]] }}}/>
title: Tiddler 1
checked: yes

<$checkbox field="checked" checked="yes" unchecked="no" checkactions=<<checkActions>> uncheckactions=<<uncheckActions>> > Check Me</$checkbox>
title: Tiddler 2
checked: yes

<$checkbox field="checked" checked="yes" unchecked="no" checkactions=<<checkActions>> uncheckactions=<<uncheckActions>> > Check Me</$checkbox>
title: Tiddler 3
checked: no

<$checkbox field="checked" checked="yes" unchecked="no" checkactions=<<checkActions>> uncheckactions=<<uncheckActions>> > Check Me</$checkbox>

If Tiddlers 1 - 3 could get a common tag or other identifier, we could move that CheckboxWidget into a ViewTemplate, and we could include a startup action to create the text for Filter Tiddler.

This has a serious deficiency, though, in that if we set the checked field to true manually, our action would not fire.

I doubt this solves your problem directly, but perhaps it’s a step in that direction.

1 Like

Try this:

title: test-index-filter

\define target() ExampleIndex

<$list filter="[tag[my-test]]">
<$checkbox tiddler=<<target>> index=<<currentTiddler>> checked="selected"  default="" uncheckactions=<<uncheckActions>>> <<currentTiddler>></$checkbox><br>
</$list>

test-index-dictionary.json (939 Bytes)

1 Like

The downside is the actual tiddler itself cannot be changed, so adding to the tags or fields is a no-go for this concept.

Ok, perhaps this would do:

\procedure chooseTiddlers(filter, filter-tiddler: "Filter Tiddler")

<$list filter={{{ [<filter>enlist-input[]] }}} >
<$checkbox
    tiddler=<<filter-tiddler>>
    listField="text"
    checked=<<currentTiddler>>
> <$link/></$checkbox><br/>
</$list>

\end

used like this:

<<chooseTiddlers "[tag[Welcome]]" "My Filter">>

Which will output checkboxes for all tiddlers matching the filter [tag[Welcome] and store the resulting filter in the text field of tiddler My Filter.

SelectTiddlers.json (866 Bytes)

Update: it would be a bit more flexible to pass the field as a parameter, defaulting to text. That’s easy enough:

\procedure choose-tiddlers(filter, filter-tiddler: "Filter Tiddler" field: "text")

<$list filter={{{ [<filter>enlist-input[]] }}} >
<$checkbox
    tiddler=<<filter-tiddler>>
    listField=<<field>>
    checked=<<currentTiddler>>
> <$link/></$checkbox><br/>
</$list>

\end

which would be used like

<<choose-tiddlers "[tag[Welcome]]" "My Filter" "my-list-field">>

SelectTiddlers2.json (965 Bytes)

1 Like