How to?: Multiple filter by tagging

194 views
Skip to first unread message

Surya

unread,
Aug 26, 2018, 5:08:57 PM8/26/18
to TiddlyWiki
Hi all,

after a long time I have again a question.
I googled and searched in this forum and tried and experimented since days. With no success :-(

I have a wiki for recipes.

So I have recipe-tiddlers and ingredient-tiddlers.
The recipe-tiddlers are tagged with either "tested" or "untested".
And the ingredients are tagged with categories- for example "butter" and "oil" are tagged with "fat". And "apple" and "orange" are tagged with "fruit".

Let's say I have now a recipe called "dessert", that is tagged with "tested" and tagged with "apple".
And I have a recipe called "drink", that is tagged with "untested" and tagged with "orange".

Now i want to make a list-filter, where I can see for example all ingredients tagged with fruit. But only these fruits, that are in recipes tagged with "tested".

So in this example it should show only the ingredient "apple". Because it is a fruit and is in a tested recipe.

How can I write this filtered list??

Thanks a lot for your help. It would make working with this wiki so much easier :-)

bimlas

unread,
Aug 26, 2018, 5:32:02 PM8/26/18
to TiddlyWiki
You can try out https://bimlas.gitlab.io/#Filter%20by%20multiple%20tags%20easily%3A%20FilteredTag%20example - the downside is that "apple" and "orange" should have a filed with the proper category instead of tag: for example "apple" has "kind=fruit". In this case https://bimlas.gitlab.io/#Filter%20by%20multiple%20tags%20easily%3A%20FilteredTag%20example would be a solution. If you type something in to the search field, the tags are filtered.

Surya

unread,
Aug 26, 2018, 6:31:34 PM8/26/18
to TiddlyWiki
Hi bimlas,
You can try out https://bimlas.gitlab.io/#Filter%20by%20multiple%20tags%20easily%3A%20FilteredTag%20example - the downside is that "apple" and "orange" should have a filed with the proper category instead of tag: for example "apple" has "kind=fruit". In this case https://bimlas.gitlab.io/#Filter%20by%20multiple%20tags%20easily%3A%20FilteredTag%20example would be a solution. If you type something in to the search field, the tags are filtered.

Thanks for your fast answer :-)
But, sorry, I do not really understand how I can write the list for my case.

I think, you mean, that I should edit this one for my case?:
<$list filter="[get[kind]] +[each:value[]sort[title]]" variable="currentKind"> <strong><<currentKind>></strong> <$list filter="[kind<currentKind>]" variable="tag"> <$macrocall $name="filteredtag" tag=<<tag>>> </$list> </$list>

Should I then write another macro for my case? And how?

And, did I understand you right, that all tiddlers, that are fruits for example should get a field called "fruit"? Couldn't I make the list with the tag "fruit", which already exists?

Please explain a bit more...
Thanks!
Surya

Mark S.

unread,
Aug 26, 2018, 6:41:28 PM8/26/18
to TiddlyWiki

How about

<$list filter="[tag[fruit]tagging[]tag[tested]]">

</$list>

?

-- Mark

Surya

unread,
Aug 26, 2018, 7:00:12 PM8/26/18
to TiddlyWiki
Hi Mark,

yeah, I hope for something easy like your suggestion.
But yours didn't work.
It shows not the ingredients, but the tested recipes.

When I change the order, it shows nothing.
I changed the order like this:

<$list filter="[tag[tested]tagging[]tag[fruit]]">

</$list>


and like this:

<$list filter="[tagging[]tag[tested]tag[fruit]]">

</$list>

I think, the solution is quite near, but still cannot find it- nevertheless lots of experiments...

Mark S.

unread,
Aug 26, 2018, 7:18:34 PM8/26/18
to TiddlyWiki
Sorry. I read too fast. Or maybe just poorly.

Possibly:

<$list filter="[tag[tested]tags[]tag[fruit]]">

</$list>

Though I feel this has a logic error somewhere.

-- Mark

Surya

unread,
Aug 26, 2018, 7:36:27 PM8/26/18
to TiddlyWiki
Hi Mark,

That's it!! :-))
I tested it now in only one case, but I think / I hope so, that it will work in my other cases too.

Thanks :-))
After writing it in a lot of tiddlers, it will save me a lot of time in future :-))

Have a good night, Surya

TonyM

unread,
Aug 26, 2018, 8:31:49 PM8/26/18
to TiddlyWiki
Surya,

Welcome back to the group, I noticed your absence.

Can I suggest in the future trying to use pseudo-code, or plan English (or your preferred language) to describe what you would have the filter do, not in terms tiddlywiki understands but how another person would understand.

For you it may make the problem so clear you can replace your code with a filter, failing that it makes it easier for others to help you.

This is what I often do and it mostly produces results.

Regards
Tony

Surya

unread,
Aug 26, 2018, 9:02:01 PM8/26/18
to TiddlyWiki
Hi,

Tony, sorry, I do not understand, what you mean. What do you mean with pseudo-code and what do you mean with plan english? And what with the rest?
Of course I want to describe my questions in a way that other people understand. But what is your suggestion for me to make that better?
(I am always working a lot with my several wikis. But just hadn't important questions. That's why I haven't been here. Unfortunately I don't think, I could answer other people questions. When I read questions of people called themselves as beginners, I could never help even them... I am sorry for that).

@Mark & all:
I thought, that I should be able now to edit this filter now to list also ingredient-tiddlers, which are either fruit OR fat AND are in recipes tagged with "tested".
But, oh my god... I am not... Tried several ways for this OR-function. But no one worked...

So please again, I ask for your help.

The recipe-tiddlers are tagged with either "tested" or "untested".
And the ingredients are tagged with categories- for example "butter" and "oil" are tagged with "fat". And "apple" and "orange" are tagged with "fruit".

Let's say I have now a recipe called "dessert", that is tagged with "tested" and tagged with "apple" and "butter".
And I have a recipe called "drink", that is tagged with "untested" and tagged with "orange" and "oil".

Now i want to make a list-filter, where I can see for example all ingredients tagged with "fruit" OR tagged with "fat". But only these fruits and fats, that are in recipes tagged with "tested".

So in this example it should show only the ingredients "apple" and "butter". Because they are fruit / fat and are in a tested recipe.


How to write the filter
<$list filter="[tag[tested]tags[]tag[
fruit]]">

</$list>
so that it finds fruits AND fats, but only of tested recipes?

Surya

Mark S.

unread,
Aug 26, 2018, 10:29:49 PM8/26/18
to TiddlyWiki
The equivalent of an "or" in filter syntax is to put in a second run:

<$list filter="[tag[tested]tags[]tag[fruit]] [tag[tested]tags[]tag[fat]]">

I'm not sure it's necessary to have an "untested" tag, though if it was me I would have an "Ingredient" tag and a "Recipe" tag. And when I say "if it were me", I mean it because I have my own recipe system that I've started where I have recipes and ingredients. Currently I'm using fields in the ingredients to indicate a relationship to recipes, but that may not have been the best way to do it. So still hammering things out.

If you ever want to list all ingredients or all recipes, it will be easier if they are all tagged accordingly. Once a recipe has been tagged as "Recipe" then it's no longer necessary (I think) to have both "tested" and "untested". Just one or the other. Or at least that's my theory.

Enjoy your just desserts!

-- Mark

TonyM

unread,
Aug 26, 2018, 11:34:47 PM8/26/18
to TiddlyWiki
Surya,

pseudo-code is documented here https://en.wikipedia.org/wiki/Pseudocode

Pseudo-code is a way or arranging your thoughts about what you want rather than how you get it, Your original question is a real mix of the two, and anyone wanting to help has to first work out what you want before they can suggest how to do it. In fact by stating clearly what you want will often give you the answer before you ask anyone.

I spent a little time analysing your post, the working is below, but I manged to determine you were asking

We could say you want either

for each tested recipe
 
Find all ingredients that are fruits

OR

for each fruit
 
See if they are in a tested recipe

So we can now make this a little more tiddlywiki like, lets go with the second, that sounds most like your request

For each tiddler tagged with fruit
 
See if that tiddler (fruit) tags at least one (recipe) tiddler

So if you asked your self how to do this you may already know the answer, but if you asked the community your question would be easier to read and answer.

Perhaps your second question should be stated in pseudo-code

"now to list also ingredient-tiddlers, which are either fruit OR fat AND are in recipes tagged with "tested"

Regards
Tony




Here is my working notes
Recipies (tiddlers) are Tested/untested
Ingredients have categories (eg fruit)
How are ingredients associated with Recipes? I will assume they are tagged with the ingredients (but what about quantities of those ingredients in a recipe?)


example content
A tested recipie tagged
with an ingredient A
An un-tested recipie tagged with an ingredient B


Desert is tested and has an apple ingrediaent
Drink is untested and has an orange ingredient


List: all ingredients tagged with fruit. But only these fruits, that are in recipes tagged with "tested".


We could say we want either


for each tested recipie
 
Find all ingrediants that are fruits


OR


for each fruit
 
See if they are in a tested recipe

Surya

unread,
Aug 27, 2018, 9:55:07 AM8/27/18
to TiddlyWiki
Hi,

@Tony: I think, my english is not good enough to really understand, what you want from me and what is pseudocode.
Maybe, I understood just a little bit, that you want, that I mark some words with colours? I try to write my questions as clearly as possible- for me.
I am sorry, that you spend time for analysing and explaining.
And hope and thank all, if you still help me with questions- also if they are not very clear for you.


@Mark: That works fine :-)
And i managed, to make another list filter by myself- yeah ;-) This one:

This lists all tested recipes, in which are fruits or fats:
<$list filter="[tag[fruit]tagging[]tag[tested]] [tag[fat]tagging[]tag[tested]] +[sort[title]]" emptyMessage="None" >
<div style="margin-left:2em;">
<li><$link><<currentTiddler>></$link></li></div>
</$list>


Now, I tried to make a list, which lists all untested recipes, in which are fruits which are also in tested recipes.

For example: A recipe called "dessert", that is tagged with "tested" and tagged with "apple" and tagged with "orange".
And a recipe called "drink", that is tagged with "untested" and tagged with "orange".
And a recipe called "icecream", that is tagged with "untested" and tagged with "pineapple".
In this example the list should show only the recipe "drink", because it is tagged with "untested" and "orange" and there is also a tested recipe, which is tagged with orange.

For the first I tried it with only fruits with
<$list filter="[tag[fruit]tagging[]tag[tested]] +[tag[fruit]tagging[]tag[untested]] +[sort[title]]" >

and with
<$list filter="[tag[fruit]tagging[]tag[tested]tag[untested]] +[sort[title]]" >

But both didn't work. I do not have more ideas, how to solve that.
Do you have an idea??

I hope, my question is very clear...
Surya

Mark S.

unread,
Aug 27, 2018, 11:56:17 AM8/27/18
to TiddlyWiki

This should work, I think:

<$list filter="[tag[tested]tags[]tag[fruit]tagging[]tag[untested]] ">

</$list>

This takes all the recipes tagged with "tested", looks at all their tags, keeps the tags that are tagged with "fruit", then looks for all the recipes tagged with those fruits, and then filters only the recipes that are untested.

Ok, now Ich habe hunger. 

-- Mark

Surya

unread,
Aug 27, 2018, 3:09:37 PM8/27/18
to TiddlyWiki
Hello Mark,

I hope, you enjoyed your meal :-)

That works perfect- thanks!
(Did my colours made my question more clear for you??)

I forgot to write, that the tags "tested" and "untested" for the recipes are not only for searching / filtering options, but also to give the recipes a different design- also different from other tiddlers. That's why I use both. On the other hand I don't have a tag "recipe". And the real name of these tags are different- RecipeTested and RecipeUntested in german. But for writing my question here I thougt, it would be easier for you with only short english words ;-)

Thank you for your nice help :-)
Surya

TonyM

unread,
Aug 27, 2018, 7:34:37 PM8/27/18
to TiddlyWiki
Surya,

Don't at all be embarrassed about your English,  feel free to keep asking questions in which ever way you wish, 
but yes your colouring and arrangement did actually make it much easier to follow.

My sharing this approach about pseudo-code was to help you improve the way you phrase questions
 and so more people can help you when your questions and examples are clearer. But you do not have to do it. 
Perhaps lookup pseudo code in your preferred language.

I hope it also helps others in this group.

Perhaps bookmark this conversation and return later when you feel more confident with your English. 
Which I may add you are already quite good at from my perspective.

Regards
Tony

Mark S.

unread,
Aug 28, 2018, 12:03:26 AM8/28/18
to TiddlyWiki


On Monday, August 27, 2018 at 12:09:37 PM UTC-7, Surya wrote:

That works perfect- thanks!
(Did my colours made my question more clear for you??)


Or at least more entertaining. ;-)
 
I forgot to write, that the tags "tested" and "untested" for the recipes are not only for searching / filtering options, but also to give the recipes a different design- also different from other tiddlers. That's why I use both. On the other hand I don't have a tag "recipe". And the real name of these tags are different- RecipeTested and RecipeUntested in german. But for writing my question here I thougt, it would be easier for you with only short english words ;-)
 
Oh, ok -- that makes sense. No fear of mixing recipes and ingredients.  Though I'm sure they'd have a good Thyme.

-- Mark

Surya

unread,
Aug 29, 2018, 3:17:12 PM8/29/18
to TiddlyWiki
@Tony & Mark:
:-)
Reply all
Reply to author
Forward
0 new messages