[TW5] How to put field value in to filter?

2,299 views
Skip to first unread message

sini-Kit

unread,
Jun 14, 2015, 11:57:40 AM6/14/15
to tiddl...@googlegroups.com
I have a tiddler with field "test" value of this field is    -[nazvanie[flower]]
I want to put this value in-to filter  <$list filter="[tag[$:/Note]]{{!!test}}" />  but it don't work.
how to put fields values in filter?


Jed Carty

unread,
Jun 14, 2015, 1:07:31 PM6/14/15
to tiddl...@googlegroups.com
This is a prproblem with how tiddlywiki parses strings. You need to use a set widget and a macro.

\define thisList()
<$list filter="[tag[$:/Note]]$(TestVariable)$" />
\end

<$set name=TestVariable value={{!!test}} >
<<thisList>>
</$set>

should work.

I have some examples up here http://inmysocks.tiddlyspot.com/#Concatenating%20Strings%20-%20What%20Breaks

Jonnan

unread,
Jun 24, 2015, 10:12:55 PM6/24/15
to tiddl...@googlegroups.com
Okay, I'm definitely not getting this syntax. Obviously I'm at the 'waving a dead chicken over it' point, but generally I *can* wave a dead chicken over it.
I want to make a generalized version of this from the tutorial: <<list-links filter:"[tag[Tag Template]] +[sort[title]]" >> where 'Tag Template' is the current tiddler.

After going through many variation trying to shoehorn variations of $title$ {title} <$title$> and currentTiddler in that spot I found this thread.
Given ...
<$set name=title value={{!!title}}
<<xxx>>
</set>

\define tags-test1() <$list filter="[tag[$(title)$]]+[sort[title]]" />
<<xxx>> returns tag1tag2tag3... no ordering, but almost what I want.

\define tags-test2() <$list-links filter="[tag[$(title)$]]+[sort[title]]" />
<<xxx>> returns Undefined widget 'list-links'

\define tags-test3() <$list-links filter:"[tag[$(title)$]]+[sort[title]]" />
<<xxx>> returns <$list-links filter:"[tag[Tag Template]]+[sort[title]]" />

I'm really not getting the syntax of the system here, even well enough to reproduce it for what ought to be really simple things, and the tutorial seems to me to skip from simple To do this one thing do 'X' to "It really quite easy you see <X{$(Y[X])$}> passes the variable as a parametrized function using the context of the Y-macro to reverse the polarity of the neutron flow".

I'd like to know where I went wrong in translating this to my tag-list function/template, but I'd really *love* to know if there an intermediate tutorial floating around somewhere that Googles not finding? I don't recall the old tiddlywiki being this obfuscated?

Eric Shulman

unread,
Jun 25, 2015, 12:49:02 AM6/25/15
to tiddl...@googlegroups.com
On Wednesday, June 24, 2015 at 7:12:55 PM UTC-7, Jonnan wrote:
Okay, I'm definitely not getting this syntax. Obviously I'm at the 'waving a dead chicken over it' point, but generally I *can* wave a dead chicken over it.

Admittedly, TW5 has it's twists and turns.  But that's because it can do so much!  Still, there is a bit of a learning curve, and the current documentation doesn't really do it justice.

Rather than trying to explain the depths of TW5 syntax here, I'll just try to answer your immediate questions...

I want to make a generalized version of this from the tutorial: <<list-links filter:"[tag[Tag Template]] +[sort[title]]" >> where 'Tag Template' is the current tiddler.

There is a built-in variable/macro named "currentTiddler".  Used in wiki syntax, you can write <<currentTiddler>> to *display* the title of the current tiddler.  To use the variable value in filter syntax, instead of [tag[text]], you can write [tag<variable>].  Thus:
<<list-links filter:"[tag<currentTiddler>] +[sort[title]]">>

After going through many variation trying to shoehorn variations of $title$ {title} <$title$> and currentTiddler in that spot I found this thread.
Given ...
<$set name=title value={{!!title}}
<<xxx>>
</set>

\define tags-test1() <$list filter="[tag[$(title)$]]+[sort[title]]" />
<<xxx>> returns tag1tag2tag3... no ordering, but almost what I want.

you could write:
filter="[tag[$(title)$]] +[sort[title]]"
(put a space between the two filter "runs")
or:
filter="[tag[$(title)$]sort[title]]"
(make one run with both tag and sort operators)

\define tags-test2() <$list-links filter="[tag[$(title)$]]+[sort[title]]" />
<<xxx>> returns Undefined widget 'list-links'

"list-links" (without the "$" prefix) is a TW core-defined *macro*.
To invoke a TW5 macro, use
<<macroname param:"value" param:"value">>
syntax.  Thus:
<<list-links filter:"[tag[$(title)$]] +[sort[title]]">>
 
\define tags-test3() <$list-links filter:"[tag[$(title)$]]+[sort[title]]" />
<<xxx>> returns <$list-links filter:"[tag[Tag Template]]+[sort[title]]" />

Macros don't "wikify" their content before returning it.  They simply return their text, unaltered except for replacing the $(variable)$ and $param$ markers with the corresponding values.

I'm really not getting the syntax of the system here, even well enough to reproduce it for what ought to be really simple things, and the tutorial seems to me to skip from simple To do this one thing do 'X' to "It really quite easy you see <X{$(Y[X])$}> passes the variable as a parametrized function using the context of the Y-macro to reverse the polarity of the neutron flow".

I can appreciate your pain.  The best way to address this is to keep asking *specific* questions that have practical application.  That way, we can zero in on *examples* that really work.

In the mean time: NEVER EVER REVERSE THE POLARITY OF THE NEUTRON FLOW.... unless you have a charge of at least 1.21 gigawatts in your flux capacitor!  (and it helps if you are going faster than 88mph).
 
I'd like to know where I went wrong in translating this to my tag-list function/template, but I'd really *love* to know if there an intermediate tutorial floating around somewhere that Googles not finding? I don't recall the old tiddlywiki being this obfuscated?

TiddlyWiki Classic was just as quirky, if not more so.  The difference is that TW5 has *much* more powerful syntax... and with that power comes complexity.  Still, it's worth the journey.  

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Jonnan

unread,
Jun 25, 2015, 8:22:49 AM6/25/15
to tiddl...@googlegroups.com
<<list-links filter:"[tag<currentTiddler>] +[sort[title]]">>

<<faceplant """Auuugh""">>

Yeah, the current documentation is flatout annoying - reviewing the filter info, I can see that now, but the context had changed so many times by the time I had gotten there I didn't even realize the significance of what I was seeing. So would [tag<title>] work just as well at that point to pull the tag from the Field?

Nope - evidently not. But aren't the fields supposed to be available as variables here? So if <currentTiddler> works, shouldn't <title> do the same thing?

Jonnan

Jed Carty

unread,
Jun 25, 2015, 2:15:33 PM6/25/15
to tiddl...@googlegroups.com
You use curly braces when it is a transclusion, so [tag{!!title}] would work. currentTiddler is a variable that is created automatically, to use anything else with the [operator<variable>] syntax you have to define the variable either using a \define or the set widget.

While it is a bit confusing to have the 3 different ways to give operators ([], <> and {}) that are used in the same place in a filter, the three things are very conceptually different.


sini-Kit

unread,
Jun 25, 2015, 2:55:22 PM6/25/15
to tiddl...@googlegroups.com
Thank you, Jed! I try to make little macros to find variants of the field values and show it as checkboxes. So I make it for one field "nazvanie" but is it possible to make it for all fields?
here is my little demo http://novye-podarki.ru/heeg208_4r.html try checkbox Roses to hide all roses from the list.  

воскресенье, 14 июня 2015 г., 20:07:31 UTC+3 пользователь Jed Carty написал:
Reply all
Reply to author
Forward
0 new messages