Dumb Question? How to combine Tags?

279 views
Skip to first unread message

Juri

unread,
Nov 18, 2019, 3:39:55 AM11/18/19
to TiddlyWiki
Is there a default way to select a combination of tags so that only the tiddlers with said combination are shown? Or how can I get a list with Checkboxes to do this?

Right now all I have is this:



<$list filter="[tag[ExampleA]tag[ExampleB]sort[title]]">

<
<currentTiddler>>

{{||$:/core/ui/ViewTemplate/tags}}

</$list>


ButI have way to many tags to use this effectively...

A Gloom

unread,
Nov 18, 2019, 4:09:36 AM11/18/19
to TiddlyWiki
This doesn't use checkboxes but select menu's and generates a filter that can be copied to a list of your design-- or you can grab the select code from it and alter it for checkboxes if you're confident with digging into code.  It's only 2 stage but does AND, OR & NOT
visual 2 stage_run filter generator.tid

Eric Shulman

unread,
Nov 18, 2019, 5:35:46 AM11/18/19
to TiddlyWiki
On Monday, November 18, 2019 at 12:39:55 AM UTC-8, Juri wrote:
Is there a default way to select a combination of tags so that only the tiddlers with said combination are shown? Or how can I get a list with Checkboxes to do this?

Here's a little experiment I just cooked up:
\define maketagfilter() tag[$(currentTiddler)$]

<style>
.columns8 { display:block; -moz-column-count:8; -moz-column-gap:1em; -webkit-column-count:8; -webkit-column-gap:1em; font-size:60%; line-height:1em; }
.columns4 { display:block; -moz-column-count:4; -moz-column-gap:1em; -webkit-column-count:4; -webkit-column-gap:1em; font-size:80%; line-height:1.4em; }
</style>

__''SELECT TAGS:''__<br>
@@.columns8
<$list filter="[all[tiddlers+shadows]tags[]sort[]]">
   <$checkbox tiddler="selectedTags" index=<<currentTiddler>> checked=<<maketagfilter>>
        checkactions="""<$action-setfield $tiddler="selectedTags" $index=<<currentTiddler>> $value=<<maketagfilter>> />"""
      uncheckactions="""<$action-setfield $tiddler="selectedTags" $index=<<currentTiddler>> />""">
         <$text text=<<currentTiddler>>/>
   </$checkbox><br>
</$list>
@@
<$wikify name="filter" text="""[all[tiddlers+shadows]<$list filter="[title[selectedTags]indexes[]]">{{{ [[selectedTags]getindex<currentTiddler>] }}}</$list>]"""> 

__''RESULTS FOR FILTER: <$text text=<<filter>>/>''__<br>
<$reveal text=<<filter>> type="nomatch" default="[all[tiddlers+shadows]]">
@@.columns4 <$list filter=<<filter>>><$link/><br></$list>@@
</$reveal>
</$wikify>

Copy the above into a tiddler and see what you get...

enjoy,
-e


HansWobbe

unread,
Nov 18, 2019, 5:18:43 PM11/18/19
to TiddlyWiki
 NEAT !!

Thanks a lot,

Hans

Eric Shulman

unread,
Nov 20, 2019, 12:49:56 AM11/20/19
to TiddlyWiki
Update: FilterGenerator now supports both AND and OR searches

Here's the new code:
<style>
.columns8 { display:block; -moz-column-count:8; -moz-column-gap:1em; -webkit-column-count:8; -webkit-column-gap:1em; }
.columns4 { display:block; -moz-column-count:4; -moz-column-gap:1em; -webkit-column-count:4; -webkit-column-gap:1em; }
.tiny   { font-size:60%; line-height:1em; }
.small { font-size:80%; line-height:1.3em; }
</style>

__select tags__:
<br>
@@.columns8.tiny

<$list filter="[all[tiddlers+shadows]tags[]sort[]]">
   <$checkbox tiddler="selectedTags" index=<
<currentTiddler>> checked=" "
        checkactions="""<$action-setfield $tiddler="selectedTags" $index=<
<currentTiddler>> $value=" " />"""

      uncheckactions="""<$action-setfield $tiddler="selectedTags" $index=<
<currentTiddler>> />""">
         <$text text=<
<currentTiddler>>/>
   </$checkbox>
<br>
</$list>
@@

<$wikify name="filter" text="""[all[tiddlers+shadows]<$list filter="[title[selectedTags]indexes[]]">tag[<
<currentTiddler>>]</$list>]""">
   <$list filter="[title[selectedTags]indexes[]count[]] -[[0]]">
      <$set name="filter_text" filter="[title[selectedTags]indexes[]join[ AND ]]">
         <$wikify name="filter_text" text=<
<filter_text>>>
            @@.small __There are <$count filter=<
<filter>>/> tiddlers tagged with <<filter_text>>__<br>@@
         </$wikify>
      </$set>
      @@.columns4.small <$list filter=<
<filter>>><$link/><br></$list>@@
   </$list>
</$wikify>

<$wikify name="filter" text="""<$list filter="[title[selectedTags]indexes[]]">[all[tiddlers+shadows]tag[<
<currentTiddler>>]] </$list>""">
   <$list filter="[title[selectedTags]indexes[]count[]] -[[0]] -[[1]]">
      <$set name="filter_text" filter="[title[selectedTags]indexes[]join[ OR ]]">
         <$wikify name="filter_text" text=<
<filter_text>>>
            @@.small __There are <$count filter=<
<filter>>/> tiddlers tagged with <<filter_text>>__<br>@@
         </$wikify>
      </$set>
      @@.columns4.small <$list filter=<
<filter>>><$link/><br></$list>@@
   </$list>
</$wikify>

I've also attached a TiddlyWiki file, based on empty.html, with the FilterGenerator already added

enjoy,
-e
filtergenerator.html

Juri der Umstrittene

unread,
Nov 26, 2019, 10:12:48 AM11/26/19
to tiddl...@googlegroups.com
Big thanks. I've changed Glooms code according to my needs and it works all right. One suggestion would be to alter the code for the drop down fields to
<$list filter='[all[tiddlers]tags[]sort[title]]'>
so the Tags are listed alphabetically. In the far away future I'll try to implement the check boxes but that was too complicated for me right now. But I'll definitely put Eric code to good use then.

The Tiddler now looks like this.
<$select field='filter-field1'>
<$list filter='[all[tiddlers]tags[]sort[title]]'>
<option value=<
<currentTiddler>>><$view field='title'/></option>
</$list>
</$select>
<$select field='filter-field2'>
<$list filter='[all[tiddlers]tags[]sort[title]]'>
<option value=<
<currentTiddler>>><$view field='title'/></option>
</$list>
</$select>
<$select field='filter-field3'>
<$list filter='[all[tiddlers]tags[]sort[title]]'>
<option value=<
<currentTiddler>>><$view field='title'/></option>
</$list>
</$select>



<$list filter="[tag{!!filter-field1}] +[tag{!!filter-field2}] +[tag{!!filter-field3}]">
<$link><$view field=title/></$link>
<br/>

{{||$:/core/ui/ViewTemplate/tags}}

</$list>
Enter code here...
The nice thing is that it shows the tag pills of the search results.

bimlas

unread,
Nov 28, 2019, 1:27:28 AM11/28/19
to TiddlyWiki
Juri,


Is there a default way to select a combination of tags so that only the tiddlers with said combination are shown? Or how can I get a list with Checkboxes to do this?

You may also be interested in this:

https://bimlas.gitlab.io/tw5-locator/ 

Search for tags by name, filter tiddlers by custom tag intersections
 
You can use the search box to search for tags by name in the Tags tab. For example, you remember a sauce recipe that could be used for chicken dishes, so you search for "sauce" and click on the tag icon next to sauces in the list because you are sure you added this tag to the tiddler (so it's a direct tag) and then search for "chicken", and you click the chain icon next to chicken in the list because you only know that it is related to the chicken topic somewhere, but you do not know the depth (ancestor tag).

TiddlyTweeter

unread,
Nov 28, 2019, 11:49:27 AM11/28/19
to TiddlyWiki
Gloom that is very neat and interesting. Having a FILTER CONSTRUCTOR, even if it can't do everything, is really useful! 
I'm sure it could be a great learning tool too. I'll be interested to see if you go further with the idea.

Best wishes
TT
Reply all
Reply to author
Forward
0 new messages