To simplify the discussion, I’ll start with a simple example.
\define test()[is[tiddler]is[shadow]sort[title]count[]]
\define test2() {{{[is[tiddler]is[shadow]sort[title]count[]]}}}
\define test3() {{{ [is[tiddler]is[shadow]sort[title]count[]join[]] }}}
\define test4()[is[tiddler]is[shadow]sort[title]count[]join[]]
<<test>>
<$text text=<<test>> />
<<test2>>
<$text text=<<test2>> />
<<test3>>
<<test4>>
<$text text={{{[is[tiddler]is[shadow]sort[title]count[]]}}}/>
The output is shown in the image above.
Only <<test2>> got the result I wanted. But it’s a missing link form that I want to turn into plain text.
I don’t want to use that last form, that’s too much filter content to write and not good for editing and maintenance. Because I will define many similar data.
Of course I know I can use lets for definitions, in fact that’s what I’m doing at the moment. But the other problem is that I would need to use the same variable in two or more entries, which I can’t do with lets. Only define, allows me to use import to achieve this.
So can anyone tell me how I should solve this problem? Or is there no suitable solution in the current situation? Any discussion I am more than welcome and appreciated.
That last form has been the only way to get what you ask for a long time until now with the release of 5.3.x
Use a function which is a form of saved filter. Its Typicaly used in other filters and can be made into custom filter operators but used as if it was a variable it does what you ask.
\function test4()[is[tiddler]is[shadow]sort[title]count[]join[]]
<<test4>>
thanks too much. it’s sloved,but i have anthor question, how i use it to display more contents? like this.
\define time-picker()
\function hour()[[$:/state/time-picker]get[hour]join[]]
\function minute()[[$:/state/time-picker]get[minute]join[]]
\function time()[<hour>addsuffix[:]addsuffix<minute>]
<$edit-text tiddler="$:/state/time-picker" field="hour"/><p/>
<$edit-text tiddler="$:/state/time-picker" field="minute"/><p/>
<<time>>
\end
<<time-picker>>
i think it should display 01:10,but it does’not. why and how to fix it ? thianks again!
remove join[] from these filter and it works, I am not sure what you were trying to join.
Although you can also use
\function time()[<hour>] [<minute>] +[join[:]]
thanks again. i use it to picker the time.
Glad I could help. Just letting you know there are other ways to make a time picker especialy if you want time of day.
Just note, this form only returns one results. For example
\function test() [tag[HelloThere]]
<<test>>
This will return only the first result!
A Gentle Guide to TiddlyWiki
While one expects all eight outpus (all tiddlers tagged with `HelloThere’).
Why sort is required for counting?
Why join is required when counting?
I assume, you can just write
\function test4() [is[tiddler]is[shadow]count[]]
and it is more performant.
- It is not needed it was just what was in the original filter.
This answer your question
Use join so the "first value is all values;
\function test() [tag[HelloThere]join[, ]]
<<test>>
- But remember this is to get a text only output