Constant operator?

169 views
Skip to first unread message

Cade Roux

unread,
Oct 2, 2020, 1:30:25 PM10/2/20
to TiddlyWiki
Is there an equivalent of a "constant" operator for a filter that doesn't effect the tiddler being selected?

I want the subfilter to allow all tiddlers through if the dropdown is the "All Tiddlers" item that has the value "--any--" or allow only tiddlers through if the customer tags field contains the selected dropdown value.

i.e. the logical equivalent of 
{$:/state/dropdownvalue} = "--any--"
OR
contains:customtagsfield{$:/state/dropdownvalue}] 

Currently I have worked around this by putting [[--any--]] in all the custom tags fields and using this subfilter:

\define selectedindropdown()
[contains:customtagsfield{$:/state/dropdownvalue}]
\end

I'd like to eliminate having to have the [[--any--]] in all the tags fields.

Something like this which doesn't select or alter the tiddler coming into the subfilter in any way, but either allows it through or not based on an unrelated condition.

\define selectedindropdown()
[constant[--any--]{$:/state/dropdownvalue} contains:customtagsfield{$:/state/dropdownvalue}]
\end

Eric Shulman

unread,
Oct 2, 2020, 1:53:53 PM10/2/20
to TiddlyWiki
On Friday, October 2, 2020 at 10:30:25 AM UTC-7, Cade Roux wrote:
\define selectedindropdown()
[constant[--any--]{$:/state/dropdownvalue} contains:customtagsfield{$:/state/dropdownvalue}]
\end

Try this:
\define selectedindropdown()
[{$:/state/dropdownvalue}match[--any--]] [contains:customtagsfield{$:/state/dropdownvalue}] +[limit[1]]
\end

Note that the subfilter is actually composed of THREE filter runs:
* The first compares the $:/state/dropdownvalue to the constant "--any--".
* The second checks if the $:/state/dropdownvalue is contained in the customtagsfield.
* The third ensures that if both the first AND second filter runs yield results, only one instance of the $:/state/dropdownvalue is returned.

In this particular use-case, the +[limit[1]] filter may not be necessary, since by design, the "--any--" value should not be in the customtagsfield.

-e

Cade Roux

unread,
Oct 2, 2020, 6:01:52 PM10/2/20
to TiddlyWiki
Thank you for looking at this, but I can't seem to get it to work.  The thing is I am working with a tiddler list, not a tag list.  The contains operator is working on the tiddlerlist and then using the custom tag:field[] operator from GenTags to give me the list of tags for the tiddlers, so after all the subfilters are applied in my run, the list is pivoted to a tags list to build the other dropdowns

I have gone ahead and put together a toy model by importing and creating tiddlers from NFL seasons 2018 and 2019, it's not a great example, but somewhat illustrates the multidimensional data aspect - which is working with the extra "--any--" in every field you want to do this with.

Thanks,

Cade

MultiDimensionalDemo.html

TW Tones

unread,
Oct 2, 2020, 8:14:39 PM10/2/20
to TiddlyWiki
Cade;

If you look at the select widget as documented;

<$select tiddler=<<qualify 'select-demo'>> default='HelloThere'>
<$list filter='[all[shadows+tiddlers]tags[]sort[title]]'>
<option value=<<currentTiddler>>><$view field='title'/></option>
</$list>
</$select>

The list if generating the options from the filter; But you can insert other options outside the list

<$select tiddler=<<qualify 'select-demo'>> default='HelloThere'>
<option value="">--any--</option>
<$list filter='[all[shadows+tiddlers]tags[]sort[title]]'>
<option value=<<currentTiddler>>><$view field='title'/></option>
</$list>
</$select>

This may lead you to a fuller answer;

Regards
Tones

Cade Roux

unread,
Oct 3, 2020, 11:18:20 AM10/3/20
to TiddlyWiki
Yes, that's what I am doing to populate the dropdowns in my example.

Team <$select tiddler="$:/state/game.teams">
<option value="--any--">All</option>
<$list filter="[all[]subfilter<game.conf>subfilter<game.division>tags:game.teams[]remove[--any--]sort[title]]"><option>{{!!title}}</option></$list>
</$select>

\define game.teams()
[contains:game.teams{$:/state/game.teams}]
\end

\define game.conf()
[contains:game.conf{$:/state/game.conf}]
\end

\define game.division()
[contains:game.division{$:/state/game.division}]
\end

<$list filter="[all[]subfilter<game.teams>subfilter<game.conf>subfilter<game.division>sort[title]]">
<$link to={{!!title}}>{{!!title}}</$link>
<br/>
</$list>

It's when attempting to change the subfilters so that I don't have to have the --any-- item in every tag list for the search to work, that I am having difficulty

MultiDimensionalDemo.html

TW Tones

unread,
Oct 5, 2020, 1:20:39 AM10/5/20
to TiddlyWiki
Cade,

I do not follow sufficiently to help I am afraid. Not sure why you share the html.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages