[TW5] Filter question: Get all field names where value is Foo

140 views
Skip to first unread message

Mat

unread,
Jan 12, 2016, 2:54:04 PM1/12/16
to TiddlyWiki
Title says it all: How do I filter out the field names where the value is Foo?

Thanx!

<:-)

Tobias Beer

unread,
Jan 12, 2016, 3:19:56 PM1/12/16
to TiddlyWiki
Hi Mat,
 
Title says it all:

True, but for the rest of us it is important to understand why you want to do the things you want to do.

How do I filter out the field names where the value is Foo?

Here's one way using tobibeer/filter:

<$vars get="[all[tiddlers]field:%inputTitle%[foo]]">

{{{ [fields[]filter:$
<get>]}}}
</$vars>

Best wishes,

Tobias.

Jed Carty

unread,
Jan 12, 2016, 4:21:52 PM1/12/16
to TiddlyWiki
Before Tobias made his filter plugin I tried for a while to get a wikitext solution to this. It is a difficult task and may not be possible using only wikitext. All the solutions I managed would repeat the returned values multiple times. Hopefully that can save you some time if you were hoping to make a wikitext solution.

Mat

unread,
Jan 12, 2016, 4:23:21 PM1/12/16
to TiddlyWiki
@Tobias - what a fast reply, fantastic!


True, but for the rest of us it is important to understand why you want to do the things you want to do.

I'm experimenting and kind of felt the context is both a bit too big for the question but mostly that it would take over the question. Buuut, since you ask, I'll describe it below especially since it's concerning something I know you also care about.
 

Here's one way using tobibeer/filter:

Great! that does work. So, TW does not have enough core features for this, right?


Ok, here's the  context:

It concerns typed tags, tag categories, semantic tagging - pick your poison. We (I and you and surely many others) have long played around with the idea of taking advantage of fields "name:value" pair to replace tags and to instead use fiels as tagtype:tagname.

At least that is how I have envisioned it until an hour ago... when it struck me that maybe I have it backwards! It should be tagname:tagtype

Possibly obvious to others, I don't know. Anyway, it seems obvious now - one only uses a tag once in a tiddler, thus it must be the unique field name- but you should be able to use tags of the same type multiple times in a tiddler, thus the field value.

A drawback is that field names, i.e what woudl be displayed on the tagpill, ehm fieldpill, is limited lowercase etc...  j.k_rowling:Author (On the other hand, the tag types can be pretty).

A more serious drawback is what you and I touched on the other day; There is currently no way to substring search field names. Thus searching for "rowling" doesn't currently work, if I understood you right. (Searching for the full j.k_rowling or author should work though as you showed me, even "auth", right?)

A niciety, when I use your filter, is that it even works to set the field value to be the string "tag" ! So, I figure one could have an "add field" feature up where the tags field currently resides and with the default field value (i.e the "type" for the supposed tag) set to be the string "tag", but changeable into anything of course (like "author" or "pupil").

I'm sure there are problems with this whole approach, but on the other hand it doesn't change any existing infrastructure. The tags field can still be around, it just wouldnt' be used, or it could be used in parallel. Maybe even practicing a distinction between tags vs categories, i.e dedicating the tags field to one thing and fieldtags to the other.

@Tobias - but also anyone

Please come with input on these thoughts.

<:-)

Mat

unread,
Jan 12, 2016, 4:25:20 PM1/12/16
to TiddlyWiki
@Jed - good to know. Yes, I did fiddle around with existing filter operators but kind of had a feeling it might not work based on some prevous discussions so had to post. Glad I did.

<:-)

Tobias Beer

unread,
Jan 12, 2016, 5:05:14 PM1/12/16
to tiddl...@googlegroups.com
Hi Mat,
 
It concerns typed tags, tag categories, semantic tagging - pick your poison. We (I and you and surely many others) have long played around with the idea of taking advantage of fields "name:value" pair to replace tags and to instead use fiels as tagtype:tagname.

At least that is how I have envisioned it until an hour ago... when it struck me that maybe I have it backwards! It should be tagname:tagtype

Quite true, I think... and actually entirely doable just using what we have already. It should be somewhat simple to construct a filter that says "give me all tiddlers that have a tag prefixed author:<anything>" ...and then display a list of those tiddlers whereas "anything" would actually point to another tiddler, namely that of the author.

So, while one could use fields for that, using tagging has the charm that we could very much so have a custom tag-template that takes such a semantic field, splits it up into its components and then "author" becomes a tagpill as well as whatever the tag-value for author is, too. However, this would introduce a new form of "tagging"... what I mean is that we'd not do [all[current]tagging[]] but rather [all[current]prefix[author:]tagging[]] to fetch all tiddlers that have the current tiddler (being a tiddler corresponding to an author) as a semantic "author-tag".

So, we actually have a host of modeling options at hand here:
  1. use an "author" field as a single-value field
  2. perhaps better:
    use an "authors" field as a list-field
  3. a few steps more generic:
    use tags via the author: prefix
  4. if you want all author data externalized:
    use a data tiddler, perhaps Authors whereas
    • key=tiddler => value=author(s) ...depending on whether you intend that as a list of authors or a single one
There's a good chance I'd tend to most always favor list fields.

Best wishes,

Tobias.

Tobias Beer

unread,
Jan 12, 2016, 5:21:25 PM1/12/16
to tiddl...@googlegroups.com
Hi again, Mat,

So, here's how you get all tiddlers having semantic author tags:

{{{ [tags[]prefix[author:]tagging[]] }}}

Here's how you'd list tiddlers with their semantically tagged authors:

<ul>
<$list filter="[tags[]prefix[author:]tagging[]sort[title]]">
<li>
<$link><$view field="title"/></$link>
<<list-links "[all[current]tags[]removeprefix[author:]]">>
</li>
</$list>
</ul>

And here listing "publications" for each semantically tagged author:

<ul>
<$list filter="[tags[]removeprefix[author:]]">
<li>
<$link><$view field="title"/></$link>
<
<list-links "[all[current]addprefix[author:]tagging[]]">>
</li>
</$list>
</ul>

And none of that needed any tobibeer/filter.

Best wishes,

Tobias.

Mat

unread,
Jan 12, 2016, 5:47:31 PM1/12/16
to TiddlyWiki
Tobias... you're seriously impressive.

I must investigate your solution and think over your list of alternative approaches properly. This will take some time for me but as you might know, the lack of typed tags has been a big obstacle for me for many years so this can be a big... well, obstacle remover ;-)

In combination with our solution for hiding tags, this should open up for a totally different way of using tags.

Thank you!

<:-)



On Tuesday, January 12, 2016 at 11:21:25 PM UTC+1, Tobias Beer wrote:
Hi again, Mat,

So, here's how you get all tiddlers having semantic author tags:

{{{ [tags[]prefix[author:]tagging[]] }}}

Here's how you'd tiddlers with their semantically tagged authors:

Tobias Beer

unread,
Jan 12, 2016, 6:04:02 PM1/12/16
to TiddlyWiki
Hi Mat,

Hope it's all useful. ;-) 
 
In combination with our solution for hiding tags, this should open up for a totally different way of using tags.

Thanks for pointing to this example.
At some point (perhaps with the core update)
the template must have gotten swallowed.
Will fix.

Best wishes,

Tobias.

Tobias Beer

unread,
Jan 20, 2016, 5:56:04 AM1/20/16
to TiddlyWiki
Hi Mat, Jed & everyone else... 
 
In combination with our solution for hiding tags, this should open up for a totally different way of using tags.

Thanks for pointing to this example.
At some point (perhaps with the core update)
the template must have gotten swallowed.
Will fix.

I have updated:

  • fixed the example for hiding tags
  • improved the template mechanism being used
    • now uses a more flexible subFilter expression to hide unwanted tags from view
Best wishes,

Tobias.

Mat

unread,
Jan 21, 2016, 9:53:09 AM1/21/16
to TiddlyWiki

I have updated:


Thank you Tobias!

For anyone who doesn't know; This creation of Tobias is independent of the other things discussed here and simply let's you control which tags to show up in viewmode. For instance, if you style a specific tiddler using tags (something that is otherwise not possible) you can now hide that ugly tag.

<:-)

Tobias Beer

unread,
Jan 21, 2016, 10:27:56 AM1/21/16
to TiddlyWiki
Hi Mat,
 
For anyone who doesn't know; This creation of Tobias is independent of the other things discussed here and simply let's you control which tags to show up in viewmode. For instance, if you style a specific tiddler using tags (something that is otherwise not possible) you can now hide that ugly tag.

Ah, good point. I've added something like your last sentence as an intro to Hide Tag Buttons @ tb5. :-)

Best wishes,

Tobias.
Reply all
Reply to author
Forward
0 new messages