Possible to have filter use value that depends on the filters output?

60 views
Skip to first unread message

Mat

unread,
Sep 11, 2017, 7:31:04 PM9/11/17
to TiddlyWiki
I stumbled on an interesting problem. Is it possible to use a value in a filter... where the value depends on the filter outcome? 

Example: Thomas Elmigers EditorCounter counts the number of characters in a text (among other things). Let's say I want to make a list of titles sorted by how many characters each tiddler has in its text field (...which is a real issue as posted here).

<$list filter="[tag[Foo]]">
<$editor-counter tiddler={{!!title}} field=text /> {{!!title}}
<br>
</$list>

...so the question is how to get the output of editorcounter into the filter.

Is it possible? Setwidget? Separate macro for editor counter?...

<:-)


c pa

unread,
Sep 13, 2017, 6:23:06 PM9/13/17
to TiddlyWiki
Mat,

When faced with this problem in the past I have always resorted to a 2 step process

1. Create a button that sets a field value in every tiddler in the Wiki = "# words in the tiddler"
2. Execute the filter sorted by that value

I haven't figured out how to execute both those steps except by writing a custom filter to do the first step. (In this case you'ld write a custom filter that counts the words in the tiddler then use that value to sort.) - look at regex[] and sort[] filter's code to see how you might do it.

Mat

unread,
Sep 14, 2017, 2:29:03 AM9/14/17
to TiddlyWiki
c pa - appreciated! Mark S gave the same reply in that other thread, so maybe that's simply how it should be done. It is really a pity that this modifies the tiddlers though. 

TWizard Tobias made a filter operator named filter to "Evaluate variable subfilters in filter expressions". I'm thinking maybe this could be used but didn't try it.

<:-)
Reply all
Reply to author
Forward
0 new messages