Filter syntax for filtering by field value

98 views
Skip to first unread message

T. E. Sanders

unread,
Feb 21, 2020, 10:53:33 AM2/21/20
to TiddlyWiki
Goodmorning all. Given that I know the value of the field "category" what syntax does one need to make this subFilter work?

   <<list-tagged-draggable tag:"todo" subFilter:"[field[{{!!category}}]]" >>

I've tried things like:
field[]has[{{!!category}}] but of course, nope.




T. E. Sanders

unread,
Feb 21, 2020, 10:56:27 AM2/21/20
to TiddlyWiki
Also tried field[category]has[{{!!category}}]. which made sense, but doesn't seem to work either.

Mark S.

unread,
Feb 21, 2020, 11:00:10 AM2/21/20
to TiddlyWiki
I don't know if this will fix your particular problem, but the filter (subfilter) should look like:

[field[{!!category}]

Basically, you use double braces {{...}} and double angle brackets <<...>> outside of filters, and single braces {...} and single angle brackets <...> inside of filters.

Eric Shulman

unread,
Feb 21, 2020, 11:11:12 AM2/21/20
to TiddlyWiki
On Friday, February 21, 2020 at 8:00:10 AM UTC-8, Mark S. wrote:
I don't know if this will fix your particular problem, but the filter (subfilter) should look like:
[field[{!!category}]
Basically, you use double braces {{...}} and double angle brackets <<...>> outside of filters, and single braces {...} and single angle brackets <...> inside of filters.

You left an extra "[" in your reply.   I'm sure it was just an editing oops!.... it should read: 
[field{!!category}]

i.e., Outer square brackets surrounding the filter, single curly braces for the filter parameter.

-e

T. E. Sanders

unread,
Feb 21, 2020, 11:14:48 AM2/21/20
to TiddlyWiki
Thanks Mark, that's good to know! I've played around with transcluding my filter inline to see what I can get, but nothing so far. I also put

  <<list-tagged-draggable tag:"todo" subFilter:"[field[category]has[{!!category}]]" >>

as my filter as a test and got "Filter error: Syntax error in filter expression". Even dropped it down to
  <<list-tagged-draggable tag:"todo" subFilter:"[field[category]]" >>. 
and still get that error. I can't see anything wrong with this filter. What could I be missing? 

Mark S.

unread,
Feb 21, 2020, 11:18:39 AM2/21/20
to TiddlyWiki
This


  <<list-tagged-draggable tag:"todo" subFilter:"[field[category]has[{!!category}]]" >>

should be


  <<list-tagged-draggable tag:"todo" subFilter:"[field[category]has{!!category}]" >>


I guess the other piece of the filter rules that I should have mentioned is that braces {}
and angle brackets <...> replace the square brackets [] of their respective filter
operators. e.g. sort[bystuff] becomes sort<myvariable>

Good luck!

Mark S.

unread,
Feb 21, 2020, 11:20:02 AM2/21/20
to TiddlyWiki
Sadly it means I need to increase the zoom on my screen. All those braces and brackets running together.

Thanks!

T. E. Sanders

unread,
Feb 21, 2020, 11:20:03 AM2/21/20
to TiddlyWiki
Actually, looking at the code for that draggable, it concats the subFilter into the main filter, so I guess I should be leaving off the [] you'd normally surround a filter with (assuming that's how you normally do it). So I tried that, and I don't get the error anymore, but it doesn't actually sub filter these based on the field called "category" with the, now hardcoded for testing value. I'm sure it's just a syntax thing on my end.

T. E. Sanders

unread,
Feb 21, 2020, 11:23:59 AM2/21/20
to TiddlyWiki
tried   <<list-tagged-draggable tag:"todo" subFilter:"[field[category]has{!!category}]" >> but got the error which I think is because this is a "sub filter" that gets concatenated. 
so tried   <<list-tagged-draggable tag:"todo" subFilter:"field[category]has{!!category}" >>. without it. No error, but still nothing returned. 
I feel like I'm close the the magic syntax though. 

Mark S.

unread,
Feb 21, 2020, 11:30:20 AM2/21/20
to TiddlyWiki
If you're just trying to make a list of things tagged "todo" that also have a category field, then this seems to do it:

<<list-tagged-draggable tag:"todo" subFilter:"has[category]" >>


T. E. Sanders

unread,
Feb 21, 2020, 11:44:27 AM2/21/20
to TiddlyWiki
Yes, that does pull up the todo list with the field category, so at least I know the subFilters aren't broken :)

What I'm trying to do though is like this:

tagged: todo

field: category with values like "today" or "next week" etc. It's a "type" of todo.

Looping over todos, then using the category as a heading over "types" of todos. The list looks like:

today:
  -- make a filter
  -- don't lose my mind

next week
  -- use my todo list
  -- do stuff


I got this to work with a regular list within a list and it looked like the above. I wanted to do it with the draggable list as the inner list instead. Which it should be able to do with a subfilter. 

The subfilter needs to filter the current tiddler (which I think the draggable macro already does)  against the value of the field "category."  I was sure something like field[category]has[today] would work, but something ain't right.

T. E. Sanders

unread,
Feb 21, 2020, 12:18:47 PM2/21/20
to TiddlyWiki
For anyone looking to create a heading delimited list like what I've outlined here that you can reorder, this is the working version:

<$list filter="[tag[todo]sort[title]each[category]]">
   <div class="series-header"><$view field='category'/></div>
   <$set name="category" value="""<$view field='category'/>""">
   <br>
          <<list-tagged-draggable tag:"todo" subFilter=field:category{!!category}  >>
   </$set>
</$list>


notice the field:fieldname{!!fieldvalue} is the syntax for filtering something by the value of a tiddler's field. 

Thanks for pushing me along Mark.

Mark S.

unread,
Feb 21, 2020, 12:28:31 PM2/21/20
to TiddlyWiki
Well, not sure if you need this:

<$list filter="[tag[todo]each[category]get[category]]">
<
<currentTiddler>><br/>
<<list-tagged-draggable tag:"todo" subFilter:"field:category
<currentTiddler>" >>
</$list>

In your version, the set widget doesn't appear to do anything.

In your version, field:category{!!category} will only work (I think) if you have a tiddler with the same name as the category which also has a field with the tiddler name in the category. Perhaps that is true with your data. Something to consider.

Good going!

T. E. Sanders

unread,
Feb 21, 2020, 12:29:49 PM2/21/20
to TiddlyWiki
Oh interesting. Thanks for that!
Reply all
Reply to author
Forward
0 new messages