[TW5] Issues understanding filters

103 views
Skip to first unread message

William RENOU

unread,
Jun 3, 2016, 2:14:43 PM6/3/16
to TiddlyWiki
I've been studying various bits of code found around various TW5, but there are some pieces I can't understand how they work.
This is one of them :
<$list filter="[is[current]field:fieldName1/fieldValue|fieldValue2/]">
 <$count filter="[field:fieldName/fieldValue3/fieldName2{{!!fieldValue3}}]"/>

 <$button message="tw-new-tiddler" class="btn-invisible" param="$:/_Template/fieldValue3> fieldValue3 </$button>
</$list>

I vaguely understand the goal of the <$button> tag, but I can't decypher the list and count filter. I've read all documentation on the operators used, but I have found nothing regarding use of / in the field operator - hard and soft parameters but nothing about / being used. The only two examples given in field Operator documentation do not use /.

My 'best' guess (and I've had many in the past few days trying to understand them) is the list filter is trying to filter tiddlers having either fieldValue or fieldValue2 as value for their fieldName1 field. Goal of the 'is[current]' is unknown.
But the <$count> filter totally evades me.

Not sure if this is relevant, but the tiddler is transcluded twice (the tiddler it's transcluded in is transcluded in another - no direct use).

PMario

unread,
Jun 3, 2016, 4:23:15 PM6/3/16
to TiddlyWiki
Hi William,

IMO it would be easier, if you tell us, where you found it.

-m

Jeremy Ruston

unread,
Jun 3, 2016, 4:40:38 PM6/3/16
to tiddl...@googlegroups.com
Hi William

On 3 Jun 2016, at 19:14, William RENOU <wilr...@gmail.com> wrote:

 I've read all documentation on the operators used, but I have found nothing regarding use of / in the field operator - hard and soft parameters but nothing about / being used. The only two examples given in field Operator documentation do not use /.

The use of the backslash to quote filter operands is an old, deprecated feature. The idea was to enable regular expressions to be used as filter operands. The problem was that each and every filter operator needed to explicitly implement support for regexps; that never happened for the core because it’s too much work with little benefit. Instead, the recommended alternative is to use the `regexp` filter operator.

When we deprecated the regexp filter operand syntax we also added a warning in the JavaScript console. You can see it by entering the sample filter in the advanced search “filter” tab and checking the JS console:

[is[current]field:fieldName1/fieldValue|fieldValue2/]

Best wishes

Jeremy.

William RENOU

unread,
Jun 3, 2016, 5:03:24 PM6/3/16
to TiddlyWiki
Got this snippet from http://tesis.tiddlyspot.com/ > $:/_notes&more

William RENOU

unread,
Jun 3, 2016, 5:23:55 PM6/3/16
to TiddlyWiki
Now I understand why it stopped working when I upgraded it from 5.0.8 to 5.1.11. Now I just need to get the 'is[current]' part.
Thanks.

c pa

unread,
Jun 3, 2016, 7:50:06 PM6/3/16
to TiddlyWiki
William,

The code with comments
<!-- create an array of all instances where the following are true:
        [is[current]      = out of all the tiddlers in the system select the current tiddler
        field:catégorie = of the tiddlers selected so far look for a field named catégorie
        field:catégorie/article = of the tiddlers selected so far look for a field named catégorie or a field named article (not sure because I'm not good on regexp)
--
        catégorie/article|livre/ = does the field contain the value article or livre?
        -- So this triggers if the current tiddler has a category of article or book
        -- The regexp no longer works and needs to be replaced with the following
        -- [regexp:catégorie[/article|livre/]] (or something I'm not up on regexp)
-->
<$list filter="[is[current]field:catégorie/article|livre/]">
<!-- Output a number = to the count of tiddlers that fit the criteria for the filter
        I think this is a search for fields named catégorie, citation or source which have a value = to the current tiddler's title
-->
   <$count filter="[field:catégorie/citation/source{!!title}]"/>
<!-- Output a hard space -->
   &nbsp;
<!-- display a button that is a copy of the tiddler named $:/_Template/Citation -->
   <$button message="tw-new-tiddler" class="btn-invisible" param="$:/_Template/Citation">cit.,&nbsp;</$button>
</$list>
<!-- display a bunch of other counts and buttons -->
<$count filter="[field:catégorie/note/à_propos_de{!!title}!description[dimensions]]"/>/<$count filter="[field:catégorie/note/search{!!title}!title{!!title}!description[dimensions]] -[à_propos_de{!!title}!description[dimensions]]"/>
<$button message="tw-new-tiddler" class="btn-invisible" param="$:/_Template/Note">notes</$button>
<$list filter="[is[current]field:catégorie/conception/]">, <$count filter="[field:catégorie/contre-exemple/à_propos_de{!!title}]"/>&nbsp;contre-exemples</$list>


Reply all
Reply to author
Forward
0 new messages