Need help with filter code

Hello,
need help with the new filter to limit the list of results according my input:

typing eg. 20 should reduce the result list to entries only with tags containing 20

\define phrase()
<span style="font-size: 0.7em; font-weight: 600; color: rgba(204, 204, 255, 0.6); border-bottom: 1px solid rgba(204, 204, 255, 0.6);">
//... als Phrase://
</span>&nbsp;
<span style="font-size: 0.7em; color: rgb(144, 238, 144);"><$text text={{{ [!is[system]search:*:literal{$(searchTiddler)$}count[]] }}}/></span>
<span style="font-size: 0.7em; color: rgba(204, 204, 255, 0.6); float: right; margin-left: 2em;"> ... Suche einschränken auf Gruppe: &nbsp;<$edit-text field=tag_selection color: rgb(255,201,102) placeholder=Wähle.../>
</span> <span style="vertical-align: middle;"></span>

<ul class="te-nav-list">
<!-- <$list filter="[!is[system]search:*:literal{$(searchTiddler)$}!sort[erstellt]limit[50]]" template="$:/plugins/telmiger/simple-search/ui/ListItemTemplate"/> -->
<$list filter="[!is[system]search:*:literal{$(searchTiddler)$}] :filter[get[tag]prefix<tag_selection>] +[!sort[erstellt]limit[50]]" template="$:/plugins/telmiger/simple-search/ui/ListItemTemplate">
</ul>

\end
<<phrase>>

What’s wrong here:

<$list filter="[!is[system]search:*:literal{$(searchTiddler)$}] :filter[get[tag]prefix<tag_selection>] +[!sort[erstellt]limit[50]]" template="$:/plugins/telmiger/simple-search/ui/ListItemTemplate">

(Of course, I have to adapt also the counter in the code)

Thanks for feedback
Stefan

You should refrain from coding html in this way. it’s not accessible. Use css instead. As a bonus, your html will be simpler and thus your macro will be simpler.

As for the filter I don’t see any problem neither, although I’m not sure what you want to do with search:*:literal{$(searchTiddler)$}. If I understand it correctly, you have a “searchTiddler” variable whose value is a tiddler name the full text of which you want to be matched by some of the fields previously selected. Am I right? I’m not so sure it was your intent.

Hello @jypre,

The plugin is from Simple Search extended with the literal option.

The initial code is:

<$list filter="[!is[system]search:*:literal{$(searchTiddler)$}!sort[erstellt]limit[50]" template="$:/plugins/telmiger/simple-search/ui/ListItemTemplate"/>

The literal output could be a long list, so I tried to implement an additional filter.
If I add tag[2022]] for testing purposes to the code, the output list will be limeted:

<$list filter="[!is[system]search:*:literal{$(searchTiddler)$}!sort[erstellt]limit[50]tag[2022]]" template="$:/plugins/telmiger/simple-search/ui/ListItemTemplate"/>

The next step was to replace tag[2022]] by a user input field …to be more flexible:

<div class="show_tag_in_search"> ... Suche einschränken auf Gruppe: &nbsp;<$edit-text field=tag_selection color: rgb(255,201,102)  placeholder=Wähle.../>
</div>

the last step was to combine both:

<$list filter="[!is[system]search:*:literal{$(searchTiddler)$}] :filter[get[tag]prefix<tag_selection>]+[!sort[erstellt]limit[50]]" template="$:/plugins/telmiger/simple-search/ui/ListItemTemplate">

…which will bring no output anymore.

Any idea?

Thanks, Stefan

Try this:

Replace

:filter[get[tag]prefix<tag_selection>]

with:

:filter[enlist{!!tags}prefix<tag_selection>]

Notes:

  • The field is named “tags”, not “tag”
  • Using enlist{!!tags} lets the :filter scan all the tags of the current tiddler for any that begin with the specified <tag_selection> value.

enjoy,
-e

I think you did misunderstand, what the limit-operator is used for

[limit[2]] means that if you get a list of 5 tiddlers, only 2 of them are shown.

Hello @EricShulman
the result list is shown again, but the additional input-filter tag-selection (2020) has no effect:

edit:
changed tag → tags in the code:

:filter[get[tags]prefix<tag_selection>]

→ shows also the list without additional additional input-filter tag-selection (2020)

I’m aware of it… thanks
The list could be very long and than it is useful to have an additional criteria to limit the list → via tags

Your code contains an $edit-text widget for you to input some tag selection text, which is stored in the tag_selection field of the current tiddler. Then, later on, within the $list filter, you refer to the <tag_selection> variable. But I don’t see any code that is actually fetching the stored tag_selection field to set the value of the variable.

Try this… just before the <ul ...>, add a line that says:

<$let tag_selection={{!!tag_selection}}>

Note that you still need to use :filter[enlist{!!tags}prefix<tag_selection>] to find the matching tag prefix. If you use :filter[get[tags]prefix<tag_selection>], you are comparing the entire contents of each tiddler’s tags field, which is stored as a single text string containing a space-separated list of individual tags. The enlist{!!tags} operator automatically chops this up into individual tags that are then each in turn compared using prefix<tag_selection>.

-e

Now it is working - thanks a lot! :+1:

I have a simple solution! (I just do the filter, please the $list widget to fit your needs.)

{{{ [enlist{!!tag_selection}listed[tags]] }}}

This solution display any tiddler with at list one of the desired tags.

To select only tiddlers having all desired tags, I propose:

{{{ [enlist{!!tagged}] :map[listed[tags]] +[unique[]] }}}

BUG: this last code only select one of all the tiddlers having all the wanted tags. The map filter prefix is at fault. I don’t remember what to use for a multi-valued yielding instead of a mono-value map, but I’m pretty sure I’ve already use such a scheme.