Howto filter by field containing 1 or more tiddler titles

Hi @all,

I got stuck building a filter by

  • Field “prio” with value “3”
  • AND field “parent-task” containing the current tiddler title. But my difficulty is
    ** that there are sometimes more than 1 tiddler-titles (can be 2 or 3 or even more)
    ** that they are written as links (inside of [[]])
    ** and sometimes they have very similar titles, like “K01: text text” and “K01: text text 1”. (Now I already put at the end always a dot for a working filter- but also without success).
  • BUT WITHOUT the tag “Nein”.

I tried it with contains, with search, with regexp- all without success. At the moment I have
<$list filter="[prio[3]search:parent-task:literal,casesensitive{!!title} -[tag[Nein]]">
And I also tried <$list filter="[prio[3]] +[search:parent-task:literal,casesensitive{!!title} -[tag[Nein]]">.

How to build such filter?

Thank you all!

You need the listed operator

By default (when you invoke it with empty argument this way [<currentTiddler>listed[]]) it scans the list field of all tiddlers to see where <currentTiddler> is named, but you can also specify an alternate field, like this (and then go on to name your other filter conditions):

{{{ [<currentTiddler>listed[parent-task]prio[3]!tag[Nein]] }}}

See whether that gets you the list you want, and come back if not?

EDIT: You were close with <$list filter="[prio[3]] +[search:parent-task:literal,casesensitive{!!title} -[tag[Nein]]"/> but… you’re missing a closing square bracket after {!!title} … and (as you realized in your post) even this version would have caught “false positives” where parent-task field names tiddlers whose titles incorporate the current one, without being identical. The “listed Operator” is designed to get you exactly the precision you need for fields that list other tiddlers’ titles (in title-list form).

Yeah, it works :slight_smile: !!

But, now I read:
If there are more than 1 titles, than inbetween should be only a space. But in my parent-task fields, I separate them like this [[title A]] ‘’&’’ [[title B]], because of better readability by transcluding the field.
Could this cause a problem?

In this particular case, probably not (unless, perhaps, you have a tiddler titled ‘’&’’.) But it’s generally good practice to keep your data and your formatting entirely separate: use the field only to list titles, and then style them in the place where they’ll be displayed. For instance, if you want to display the list of titles as links separated by &, you could do something like this:

<$list filter="[enlist{!!parent-task}]" join=" ''&'' " />

On the other hand, if your parent-task field includes wikitext or other stylistic elements, you won’t be able to use filter operators like enlist without having to filter out some undesired results.

  • If parent-task: [[title A]] ‘’&’’ [[title B]]
  • then {{{ [enlist{!!parent-task}] }}} will give you a list of links to title A, title B, and the nonexistent tiddler ‘’&’’.

I understand it’s tempting to style your field contents so they can be transcluded as-is, but this will really limit the number of ways in which you can reuse them. And from experience, it will be much easier to correct this sooner rather than later!

If you have a lot of fields where you’ve done this sort of thing, I’ve found that the Commander plugin is the easiest way to clean them up: it has a search-and-replace feature that will really help with batch-editing.

2 Likes

I concur entirely — the best practice is to make sure any field containing a list of tiddler titles should avoid adding any other stuff.

One reason — beyond the complication that arises if you have a tiddler with a name like & — is that a list field is a place where order can matter, and repeated values are treated as redundant.

There are various tools in TiddlyWiki that can help you work with this ordering, and they all assume that repeated values can be dropped. For example, see this: https://tiddlywiki.com/#list-links-draggable%20Macro

(In fact, the tags field of any tiddler is just a list field, and you may have already noticed that the tag pill dropdown menu allows you to customize the order of titles. That order is stored in the list field of the tag tiddler.)

If a title-list field contains separators such as the & character, then that character will appear in the list-links-draggable interface just once, and once you drag titles up and down, you will lose all but one of your & separators, since list-handling is designed to avoid duplicate values.

I realize it’s a learning curve! But keeping the title-list field straightforward (while replacing any simple transclusion of that title-list field with the variant suggested by @etardiff<$list filter="[enlist{!!parent-task}]" join=" ''&'' " /> to keep the look you want) will get you into good habits!

2 Likes

Ok… I’ll do it like that. Thanks for your awareness!

1 Like