filter question

63 views
Skip to first unread message

paulgilbert2000

unread,
Jul 25, 2021, 8:28:30 PM7/25/21
to TiddlyWiki

Hi ,

is it possible to assign an action to a button that would affect some but not all tiddlers listed in a filter

so for example, i want to add "tag1" to all tiddlers tagged with "example1"

<$button> add tag 1
<$list filter="[tag[example1]]" >
<$action-setfield tags="tag1"/>
</$list>
</$button>

but i also want to see all tiddlers tagged with  "example1", "example2" and  "example3"..

i can modify the filter to add all tiddlers tagged with "example1" , "example2", "example3",  ... but then if i click the button the action will affect all tiddlers , so is there way to set an action against some tiddlers meeting a  certain criteria while keeping other tiddlers that don't  not matching the criteria on display?

Frédéric Demers

unread,
Jul 25, 2021, 9:55:21 PM7/25/21
to TiddlyWiki
Hi Mohammad, can you expand a bit about the list you want to see? is this just when you click the button?
One issue is that the setfield will replace the example1 tag with tag1. Did you mean to show the list only after the change happened, or did you mean to add tag1 to the tiddlers that also have example1?
If you want to add a tag, you would be better off using the <$action-listops $tags="tag1"/> instead of <$action-setfield tags="tag1"/>
This will get you part way there...

<$button>refresh list and add tag 1
<!-- clear the field -->
<$action-listops $field="myfield" $filter="[[]]"/>
<!-- populate the field -->
<$list filter="[tag[example1]] [tag[example2]] [tag[example3]]" variable="lister">
<$action-listops $field="myfield" $subfilter="[enlist<lister>]"/>
</$list>
<!-- add tag1 -->
<$list filter="[tag[example1]]">
<$action-listops $tags="tag1"/>
</$list>
</$button>

<!-- display the field -->
<$list filter="[list[!!myfield]]">

</$list>


TW Tones

unread,
Jul 26, 2021, 3:13:14 AM7/26/21
to TiddlyWiki
As fred points out  <$action-setfield tags="tag1"/> is to set the whole tags field to tag1, obliterating any other contents.

Since tags can hold more than one tagname or title you must treat it as a list and use the actions designed for tags or use the listop actions. Unless of course you want "obliteration" of the tags field.

Regards
Tones

paulgilbert2000

unread,
Jul 26, 2021, 1:44:32 PM7/26/21
to TiddlyWiki
Thanks guys,
 
i don't mind the tag being replaced, i was more interested to know how to apply actions  to some but not all tiddlers listed, the button is there only to add the tag and  not to display the list, i just want the button  to add the tag to only a subset of the list  that is tagged with example1

hope this makes sense
Reply all
Reply to author
Forward
0 new messages