How-To?: Search/Filter by multiple Tags with checkboxes or buttons for tags /taggroups

422 views
Skip to first unread message

Surya

unread,
Feb 6, 2018, 8:37:50 PM2/6/18
to TiddlyWiki
Hello,

one big wish I have:

I want to be able to search / filter by multiple tags with the following features:

  • The tags should be visible & choosable
    • The best would be checkboxes for each tag by which I want to choose. But maybe it could be also possible with buttons, which add the wanted tags to a search field.
  • These tags should be nested by their parent tags (expandable). For example, the following is shown "Countries", "Persons" and "Work or Holiday". When I click on "Countries" all child-tags of "Countries" will be shown ("Holland", "India", "Japan",....). I choose Japan and make the parent tag "Countries" shrinked. Then I click on "Persons" >all child-tags of "Persons" are shown and I choose "Tom" & "Linda". Now all tiddlers, which are tagged with Japan & Tom & Linda are shown. I made a picture of what I mean with nested & expanded & shrinked tags (from the software "digiKam".
  • If I added a tag to search-by, I want to be able to remove that tag very easy & fast- like in $:/plugins/danielo/tagSearch. There the added tags are shown as the tagpills with their x in it.
  • The found tiddlers should be shown as a list of links.
  • Before the list of results it should be shown, how many tiddlers are found.
  • Last, but not least, I want to be able at the end to filter the results by prefixes of the title.
  • And finally there should be a button with "Open all found tiddlers".


Only as a cream topping, but not essential:

  • It would be great, if I could also be able to filter by ratings ($:/plugins/tobibeer/rate)
  • And fantastic, if it would be also possible, to filter not only by AND, but additionally by OR. For example "Find all tiddlers tagged with Japan AND Tom OR Linda AND Holiday. So it would find all tiddlers tagged with Japan & Tom & Holiday but also tiddlers tagged with Japan & Linda & Holiday. For each tag I want to be able to choose if AND or OR (default AND). But I guess, that isn't possible, is it?!?

I found some interesting Solutions like http://checklist.tiddlyspot.com/ & $:/plugins/danielo/tagSearch and others, but all of them fitted only parts of my need. And I don't know, how to combine them. I tried already to modify them, but only partly successful.


Can you help me with that?? PLEASE :-)
Surya



Gewünschte multiple Tagsuche.jpeg

TonyM

unread,
Feb 6, 2018, 8:51:12 PM2/6/18
to TiddlyWiki
Surya,

FYI There is the CheckBox Widget in the core now


Regards
Tony

Surya

unread,
Feb 6, 2018, 9:05:31 PM2/6/18
to TiddlyWiki
Hi Tony,


FYI There is the CheckBox Widget in the core now

Yes, I saw that while searching since weeks for solutions for my big wish.

But, excuse me, I have no- really not a little- idea, how to write , to get my wanted search/filter.

I have some of my experiments related to this topic in my http://suryas-testwiki.tiddlyspot.com/#, they are tagged with Search.

Surya

TonyM

unread,
Feb 7, 2018, 2:07:44 AM2/7/18
to TiddlyWiki
Surya,

It nice to hear of what you dream. I know I could build this using MyMenus Plugin I just released, 

To support Tagging;
Perhaps a menu With each tag group a sub menu (where you can check the required ), tags on the tiddler, then in the same top menu list all currently tagging with checkboxes to remove them.

Then a similar process would be used in the display of tiddlers, tagged with your various combinations, this will be part of a future view/report tiddler I plan to design later.

Unfortunately I am away from my desk for 4 weeks

Regards
Tony

Mark S.

unread,
Feb 7, 2018, 10:31:18 AM2/7/18
to TiddlyWiki
Here's an ugly, proof-of-concept approach. Make a tiddler:

<$macrocall
    $name="toc-tabbed-internal-nav"
    tag="TableOfContents"
    selectedTiddler="$:/temp/toc/selectedTiddler"
    unselectedText="
<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText="
<p>Missing tiddler.</p>"
template="CheckboxTemplate"
/>
<$edit-text tiddler=additionalCriteria tag=input size=20 />
<br>
<
<list-links "[field:criteria[yes]prefix{additionalCriteria}]">>

Then make a template tiddler called CheckboxTemplate with these contents:

<$checkbox field="criteria" tag={{!!title}} checked="yes" unchecked="no"/> {{!!title}}Enter code here...

Now you can check tiddlers using the checkbox that appears to the right in the TOC tag tree. The results appear below. You can filter the results with the edit box.

There are lots of refinements possible.

Good luck,

-- Mark

Surya

unread,
Feb 8, 2018, 3:23:09 PM2/8/18
to TiddlyWiki
Hi Mark,


Am Mittwoch, 7. Februar 2018 16:31:18 UTC+1 schrieb Mark S.:
Here's an ugly, proof-of-concept approach. Make a tiddler:

<$macrocall
    $name="toc-tabbed-internal-nav"
    tag="TableOfContents"
    selectedTiddler="$:/temp/toc/selectedTiddler"
    unselectedText="
<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText="
<p>Missing tiddler.</p>"
template="CheckboxTemplate"
/>
<$edit-text tiddler=additionalCriteria tag=input size=20 />
<br>
<
<list-links "[field:criteria[yes]prefix{additionalCriteria}]">>

Then make a template tiddler called CheckboxTemplate with these contents:

<$checkbox field="criteria" tag={{!!title}} checked="yes" unchecked="no"/> {{!!title}}Enter code here...

Now you can check tiddlers using the checkbox that appears to the right in the TOC tag tree. The results appear below. You can filter the results with the edit box.

There are lots of refinements possible.

Good luck,

-- Mark

Thanks a lot for your solution :-)
I think, that is going to the direction I want.
But: It doesn't work.... I mean, it works wrong ;-)

For testing it, I made on my testing-wiki http://suryas-testwiki.tiddlyspot.com/ a parent tiddler-tag called "Character". And I made some child-tags (A, B, C, D, E). And I made some tiddlers having some of the child-tags (New Tiddler 1-6). All the tiddlers related to your suggestion are tagged with "Search by Mark".

  • When I choose "A" by clicking the checkbox, it should list the tiddlers: New Tiddler 1, New Tiddler 4, New Tiddler 5. But it lists "A". When I choose "B", it should list the tiddlers: New Tiddler 1, New Tiddler 2, New Tiddler 6. But it lists "B".
  • When I choose "A" by clicking the checkbox, it adds the tag "B" to the tiddler "B".
Did I do anything wrong? Or did you missunderstand me?
How should I edit it?

Surya

Surya

unread,
Feb 8, 2018, 3:26:09 PM2/8/18
to TiddlyWiki
Oh, sorry, I wrote something wrong:

  • When I choose "A" by clicking the checkbox, it adds the tag "B" to the tiddler "B".
I meant:  When I choose "A" by clicking the checkbox, it adds the tag "A" to the tiddler "A". And, of course the same with example "B": When I choose "B" by clicking the checkbox, it adds the tag "B" to the tiddler "B".

Mark S.

unread,
Feb 8, 2018, 4:20:39 PM2/8/18
to TiddlyWiki
Oops. Change CheckboxTemplate to

<$checkbox field="criteria"  checked="yes" unchecked="no"/> {{!!title}}Enter code here...

and Search made by Mark to:

\define addCrit() $(additionalCriteria)$
<$macrocall
    $name
="toc-tabbed-internal-nav"
    tag
="TableOfContents"
    selectedTiddler
="$:/temp/toc/selectedTiddler"
    unselectedText
="<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText
="<p>Missing tiddler.</p>"
template="CheckboxTemplate"
/>
<$edit-text tiddler=additionalCriteria tag=input size=20 /><br>
<$vars additionalCriteria={{additionalCriteria}}>
<<list-links "[field:criteria[yes]tagging[]regexp<addCrit>]">>
</$vars>

That worked with your test site, which is very nice BTW.

-- Mark

Mark S.

unread,
Feb 8, 2018, 4:21:31 PM2/8/18
to TiddlyWiki
Take out "Enter code here..." which is something left over from the gügle editor.

-- Mark

On Thursday, February 8, 2018 at 1:20:39 PM UTC-8, Mark S. wrote:
Oops. Change CheckboxTemplate to

<$checkbox field="criteria"  checked="yes" unchecked="no"/> {{!!title}}

Surya

unread,
Feb 8, 2018, 6:34:12 PM2/8/18
to TiddlyWiki
Hi Mark,

with that the basic function works- thanks :-)

Now the second: When I choose more than one tag, it lists all tiddlers which have either the one tag or the other tag. It seems to be a search with "OR". But it should be a filter with AND. With AND it should list less tiddlers, the more tags I choose.
For example: Choosing "A" & "B" should list then only "New Tiddler 1". Now it lists "New Tiddler 4", "New Tiddler 5", "New Tiddler 1", "New Tiddler 2", "New Tiddler 6.

And it should sort the listed tiddlers by title. I couldn't see, where to write the wanted sorting in.

I am looking forward to build my wished "Multiple tag filter" step by step :-)
Surya

Mark S.

unread,
Feb 8, 2018, 10:26:11 PM2/8/18
to TiddlyWiki
Since your tags are in a tree, I didn't think it was possible for items to be both A and B.

Oh well. Try replacing Mark's Search with these contents:

\define addPrefix() +[tag[
\define addSuffix() ]]
\define finalFilter()  [all[tiddlers]] $(myfilter2)$ +[regexp[$(additionalCriteria)$]]


<$macrocall
    $name
="toc-tabbed-internal-nav"
    tag
="TableOfContents"
    selectedTiddler
="$:/temp/toc/selectedTiddler"
    unselectedText
="<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText
="<p>Missing tiddler.</p>"
template="CheckboxTemplate"
/>
<$edit-text tiddler=additionalCriteria tag=input size=20 /><p/>
<$vars additionalCriteria={{additionalCriteria}}>

<$set filter="[field:criteria[yes]addprefix<addPrefix>addsuffix<addSuffix>]" name=myfilter>

<$wikify text=<<myfilter>> name=myfilter2 type=text>

<$macrocall $name=list-links filter=<<finalFilter>> />

</
$wikify>
</$set>
</
$vars>


I think I may have invented a new approach to this kind of problem where you need to take a list of items and turn them into a single filter.

Have fun
-- Mark

Surya

unread,
Feb 9, 2018, 2:27:24 PM2/9/18
to TiddlyWiki
Hiho Mark,

it works :-)))
strangely & unfortunately not on my test-wiki anymore. But on one of my private wikis (so it should work on all my private wikis, I think & hope) and on my other wiki on tiddlyspot.

So, the both main features are working.
Now coming to the fine tuning :-) Should I list all fine tuning wishes at once? Or one after the other?

Well, I'll write now all (because I guess, that some wishes depend on other wishes for writing the command). The numbered list is the first priority, then the rest comes :-)
  1. Because of the Plugin $:/plugins/eucaly/popuptagger it shows in the TableOfContents in the "Search made by Mark" the tiddler $:/temp/pptg-taggroup as a child-tag of every parent-tag. How can I hide that tiddler from the TableOfContents in the "Search made by Mark"?

  2. In the TableOfContents in the "Search made by Mark" there are also the tiddlers listed, which have the listed tags (for example in the test-wiki the New Tiddler 1, New Tiddler 2, and so on... How can I hide them from the TableOfContents in the "Search made by Mark"?

  3. I would like to have the checkboxes directly next to the listed tags (for example in the test-wiki the checkbox for "A" next to "A"). In that way I would have to do one click-action less. And also I could see much faster, which tags I have checked / not checked. Because, when I would click on the arrow of a parent-tag I could see ALL child-tags of their parent-tag WITH their checkboxes at once.

    • It wouldn't matter to me, if ALL the child-tags WITH their checkboxes are inside the TableOfContents or in the white space on the right side of the TableOfContents.

  4. I'd like to have the checked tags shown between the "Additional criteria"-Search-Field and the list of found tiddlers. For to know "By which tags did I do the filtering?" With the information "These tags you have chosen" (or similar) before it.
  • If I added a tag to search-by, I'd like to be able to remove that tag very easy & fast- like in $:/plugins/danielo/tagSearch. There the added tags are shown as the tagpills with their x in it.
  • Before the list of results it should be shown, how many tiddlers are found.
  • The "Additional criteria"-Search-Field: At the moment it is like this:
    • When a write in "an", it lists the tiddlers with "an" somewhere in the title.
    • When I write in that search field "An", then it lists the tiddlers beginning with "An".
      • So it seems, that this filter is sensitive for capital & non-capital letters. It would be nice, if it would dosen't matter, if I write "an" or "An"- it should list in both ways the tiddlers beginning with "An" and "an".
  • And finally there should be a button with "Open all found tiddlers".
    I hope, that I don't want to much from you ;-)
    Thanks a lot lot lot. Surya

    Mark S.

    unread,
    Feb 10, 2018, 9:46:42 PM2/10/18
    to TiddlyWiki
    1.  I don't know anything about the popup-tagger. Is this change incorporated into your test wiki? I'm not seeing anything odd.
    2. I think the "toc-tabbed-internal-nav" code would need to be hacked to stop presenting results for "children" (tiddlers without tag descendants).
    3. Same as #2
    4. As a starter, insert this:

    Tags used: <<list-links "[field:criteria[yes]]">>

    just before the </$wikify> closing tag.

    For the case sensitivity issue, update the finalFilter macro to read:

    \define finalFilter()  [all[tiddlers]] $(myfilter2)$ +[regexp[(?i)$(additionalCriteria)$]]

    I was kind of hoping that by now someone would jump in with a ready-made, turnkey solution for you ;-)

    -- Mark

    Surya

    unread,
    Feb 11, 2018, 1:25:38 PM2/11/18
    to tiddl...@googlegroups.com
    Hello Mark,

    I got your solution (now called "MultipleTagSearch", but still everything related to it tagged with "Search by Mark") to work again on my test-site http://suryas-testwiki.tiddlyspot.com.


    I don't know anything about the popup-tagger. Is this change incorporated into your test wiki? I'm not seeing anything odd.
    I imported the popup-tagger to show, what I meant. The affect on every normal tiddler is the grey bar below the tags. There I have grouped tags by their parent tags and can add them quite fast to a tiddler. Every parent tag is then listed in that $:/temp/pptg-taggroup.


    I think the "toc-tabbed-internal-nav" code would need to be hacked to stop presenting results for "children" (tiddlers without tag descendants).
    Yes, I think so. But don't know how to hack that.
    Or maybe, not doing it with the toc-...? But with anything else?


    For showing the choosed tags:
    Your suggestion works :-)
    But I modified it like this and managed to add a count :-) :

    Choosed Tags: <$list filter="[field:criteria[yes]]" storyview="pop"><$set name="backgroundColor" value={{!!color}}><span style=<<tag-styles>> class="tc-tag-label">
    <$view field="title" format="text" />
    <$button message="tm-remove-tag" param={{!!title}} class="tc-btn-invisible tc-remove-tag-button">&times;</$button></span>
    </$set>
    </
    $list>
     
    <div style="display:inline;"><<show-system>></div>

    <$count filter=<<finalFilter>> /> matching tiddler:

    <$macrocall $name=list-links filter=<<finalFilter>> /
    >



    I was kind of hoping that by now someone would jump in with a ready-made, turnkey solution for you ;-)
    Maybe, someone else can help?
    Hello @all....!

    Thanks a ton to you :-)
    Surya

    Mark S.

    unread,
    Feb 11, 2018, 4:00:17 PM2/11/18
    to TiddlyWiki
    Is there some reason that $:/temp/pptg-taggroup is tagged as Character ? It seems to work without the tag.

    -- Mark

    Surya

    unread,
    Feb 11, 2018, 5:04:15 PM2/11/18
    to tiddl...@googlegroups.com
    Hi Mark,


    Is there some reason that $:/temp/pptg-taggroup is tagged as Character ? It seems to work without the tag.

    That is done automatically by the plugin.

    I tried it. Added one more parent-tag. And deleted both parent-tags from
    $:/temp/pptg-taggroup. And, you're right, the popup-tagger is still working and the MultipleTagSearch too :-)

    Fine :-)

    Surya

    unread,
    Feb 12, 2018, 3:08:24 PM2/12/18
    to TiddlyWiki
    Hello,

    I managed now to add an "open all"-button to the MultipleTagSearch with this:

    <$button>Open ''ALL found'' Tiddlers
    <$list filter=<
    <finalFilter>>>
    <$action-navigate $to=<
    <currentTiddler>> $scroll=no/>
    </$list>
    </$button>
    (Found that somewhere in the web and modified it to work in the MultipleTagSearch).


    But still there are these unsolved problems (point 1. & 2. are the most important ones):
    1. In the "MultipleTagSearch" there are also the tiddlers listed, which have the listed tags (for example in the test-wiki the New Tiddler 1, New Tiddler 2, and so on... How can I hide them in the "MultipleTagSearch"?

    1. I would like to have the checkboxes directly next to the listed tags (for example in the test-wiki the checkbox for "A" next to "A"). In that way I would have to do one click-action less. And also I could see much faster, which tags I have checked / not checked. Because, when I would click on the arrow of a parent-tag I could see ALL child-tags of their parent-tag WITH their checkboxes at once.

      • It wouldn't matter to me, if ALL the child-tags WITH their checkboxes are inside the TableOfContents or in the white space on the right side of the TableOfContents.

    • If I added a tag to search-by, I'd like to be able to remove that tag very easy & fast- like in $:/plugins/danielo/tagSearch. There the added tags are shown as the tagpills with their x in it.
    • The "Additional criteria"-Search-Field: At the moment it is like this:
      • When a write in "an", it lists the tiddlers with "an" somewhere in the title.
      • When I write in that search field "An", then it lists the tiddlers beginning with "An".
        • So it seems, that this filter is sensitive for capital & non-capital letters. It would be nice, if it would dosen't matter, if I write "an" or "An"- it should list in both ways the tiddlers beginning with "An" and "an".
      Maybe, it would be better, not to use TableOfContents, but something else (so that the unwanted tiddlers could be hidden from the choosable tags)?
      But I still couldn't find out how. Experimented a lot....

      Please, all TW-freaks ;-) Please help...
      I'll give hundreds of kisses ;-)
      Surya

      Surya

      unread,
      Feb 24, 2018, 7:57:31 PM2/24/18
      to TiddlyWiki
      Hello again,

      I still didn't find a complete solution for my Search/Filter by multiple Tags.

      The most important features in this solution made by Mark S. I still dind't find a solution for:
      • Having only the tags listed, that I want to have listed (without the tiddlers listed, which have the listed tags- for example in the test-wiki the New Tiddler 1, New Tiddler 2, and so on..., but only the tags "A", "B", "C", and so on...)
        • I wouldn't mind to list all wanted tags by myself >it isn't necessary to have the TableOfContents for listing the tags.

      • I need checkboxes next to every listed tag to have the possibility for choosing.
      Please could you help me with this.
      Yes, I am asking similar questions in this thread: https://groups.google.com/forum/#!topic/tiddlywiki/rHugihm1J70. It is for the same goal, but with a completely different approach. So I think, it is better, to have these in two different threads, because both have completely different approaches.

      You can see & play around with both on
      I experimented so much with them, but I cannot solve it...
      Thanks for your help!
      Surya

      Surya

      unread,
      Feb 28, 2018, 2:56:16 PM2/28/18
      to TiddlyWiki
      Hello Mark (and all others),

      Many many hours of experiments and googling later....
      I found out now, how I can show only the tags I want to show and to have checkboxes for each tag I want to search by :-)

      I have now only 3 issues anymore. And for that I found just ..... nothing. Nothing how I could solve that.

      1. The checkbox for the tags seems not to be fixed to the tag-title, to which it belongs. That means, if there isn't enough space anymore for the tag-title, the tag-title moves to the next line (if it is without space in it). But the checkbox doesn't move to the next line (on suryas-testwiki it is the tag "E:Anewcharacter"). And if the tag-title has symbols or spaces in it, it is moved only partly to the next line. What can I do, that the tag-title is moved alltogether and with the checkbox to the next line?
      2. If no tag is choosed, there are ALL tiddlers listed. In this way, this search-tiddler gets very very long. How can I solve it, that there is no tiddler shown, when I open that search-tiddler and have no choosen tag?
      3. At the end of the search-tiddler it shows </$vars>. Where is my mistake?
      You can see it on http://suryas-testwiki.tiddlyspot.com/#MultipleTagSearch%20by%20Mark.

      The full command in that search-tiddler is now:
      \define addPrefix() +[tag[
      \define addSuffix() ]]
      \define finalFilter()  [all[tiddlers]!is[system]] $(myfilter2)$ +[regexp[^$(additionalCriteria)$]]

      <div style="background:plum;">

      <$reveal type="nomatch" state="$:/state/SampleRevealMTSG&W" text="show">

      <$button set="$:/state/SampleRevealMTSG&W" setTo="show">Show tags for @@color:green;"Character"@@</$button>
      </$reveal>
      <$reveal type="match" state="$:/
      state/SampleRevealMTSG&W" text="show">

      <$button set="
      $:/state/SampleRevealMTSG&W" setTo="hide">Hide tags for @@color:red;"Character"@@</$button>
      &nbsp;&nbsp;&nbsp;<$list filter="
      [tag[Character]![$:/temp/pptg-taggroup]sort[title]]" template="$:/core/ui/TagTemplate"
          selectedTiddler="
      $:/temp/selectedTiddler"
          unselectedText="<p>
      Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
          missingText="<p>
      Missing tiddler.</p>"
      template="
      CheckboxTemplate"
      />
              <$reveal type="
      nomatch" state="$:/state/SampleRevealMTSAll" text="show">

      <$button set="
      $:/state/SampleRevealMTSAll" setTo="show">Show tags for @@color:green;"New Character"@@</$button>
      </$reveal>
      <$reveal type="
      match" state="$:/state/SampleRevealMTSAll" text="show">

      <$button set="
      $:/state/SampleRevealMTSAll" setTo="hide">Hide tags for @@color:red;"New Character"@@</$button>
      &nbsp;&nbsp;&nbsp;<$list filter="
      [tag[New Character]![$:/temp/pptg-taggroup]sort[title]]" template="$:/core/ui/TagTemplate"
          selectedTiddler="
      $:/temp/selectedTiddler"
          unselectedText="<p>
      Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
          missingText="<p>
      Missing tiddler.</p>"
      template="
      CheckboxTemplate"
      />
      </$reveal>

      </$reveal>


      <br/>

      <$edit-text tiddler=additionalCriteria tag=input size=20 /><p/>
      <$vars additionalCriteria={{additionalCriteria}}>

      <div style="background:white;"><br/>

      <$set filter="
      [field:criteria[yes]addprefix<addPrefix>addsuffix<addSuffix>]" name=myfilter>


      <$wikify text=<<myfilter>> name=myfilter2 type=text>

      Choosed Tags: <$list filter="[field:criteria[yes]sort[title]]" storyview="pop"><$set name="backgroundColor" value={{!!color}}><span style=<<tag-pill-styles>> class="tc-tag-label">
      <$view field="
      title" format="text" />
      <$button message="
      tm-remove-tag" param={{!!title}} class="tc-btn-invisible tc-remove-tag-button">&times;</$button></span>
      </$set>
      </$list>
       <div style="
      display:inline;"><<show-system>></div>


      <$button>Open ''ALL found'' Tiddlers
      <$list filter=<<finalFilter>>>
      <$action-navigate $to=<<currentTiddler>> $scroll=no/>
      </$list>
      </$button>

      <$count filter=<<finalFilter>> /> matching tiddler:

      <$macrocall $name=list-links filter=<<finalFilter>> />

      </$wikify>
      </$set>
      </$vars>


      And the command in the Checkbox Template is:

      <$checkbox field="criteria"  checked="yes" unchecked="no"/>{{!!title}}&nbsp;&nbsp;&nbsp;&nbsp;

      Friendly asking- Surya

      Reply all
      Reply to author
      Forward
      0 new messages