Can I add the advanced search with a Filter under the normal search?

60 views
Skip to first unread message

Rafael Oliveira

unread,
Aug 2, 2020, 5:35:51 PM8/2/20
to tiddl...@googlegroups.com
I'd like to have the advanced searching option with a filter available on the main page of my TW like the following:

But the configuration on ControlPanel/Appearance/Toolbars/Page Toolbar doesn't list even the normal search... Is there an easy way of adding the Filter functionality directly on my main page?

Eric Shulman

unread,
Aug 2, 2020, 5:52:04 PM8/2/20
to TiddlyWiki
On Sunday, August 2, 2020 at 2:35:51 PM UTC-7, Rafael Oliveira wrote:
I'd like to leave the searching option available on the main page of my TW like the following:
But the configuration on ControlPanel/Appearance/Toolbars/Page Toolbar doesn't list even the normal search... Is there an easy way of adding the Filter functionality directly on my main page?

The UI for the $:/AdvancedSearch, Filter panel is here: $:/core/ui/AdvancedSearch/Filter

To add this to the SideBar, edit the tiddler and add a tag: $:/tags/SideBarSegment

You can re-position the Filter UI by using drag-n-drop within that tag pill.

-e

 

Rafael Oliveira

unread,
Aug 2, 2020, 6:15:02 PM8/2/20
to TiddlyWiki
I see that the second line is responsible for the text above the search bar:

\define lingo-base() $:/language/Search/
<<lingo Filter/Hint>>

<div class="tc-search tc-advanced-search">
<$edit-text tiddler="$:/temp/advancedsearch" type="search" tag="input" focus={{$:/config/Search/AutoFocus}}/>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/AdvancedSearch/FilterButton]!has[draft.of]]"><$transclude/></$list>
</div>

...

It's just a small detail that is not a problem if not possible. But, the tiddlywiki syntax looks like a Markup language as HTML... Considering that, is it possible to include conditions? I mean, on the code above it'd be nice if I could add a condition that relies on the tag used. The pseudocode would look like:

\define lingo-base() $:/language/Search/
if ( tag === "$:/tags/AdvancedSearch" ) {
   
<<lingo Filter/Hint>>
}

<div class="tc-search tc-advanced-search">
<$edit-text tiddler="$:/temp/advancedsearch" type="search" tag="input" focus={{$:/config/Search/AutoFocus}}/>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/AdvancedSearch/FilterButton]!has[draft.of]]"><$transclude/></$list>
</div>

This way I'd only see the text when the tag used is the original one. Is something like this possible?

Eric Shulman

unread,
Aug 2, 2020, 6:31:08 PM8/2/20
to TiddlyWiki
On Sunday, August 2, 2020 at 3:15:02 PM UTC-7, Rafael Oliveira wrote:
it'd be nice if I could add a condition that relies on the tag used. The pseudocode would look like:
\define lingo-base() $:/language/Search/
if ( tag === "$:/tags/AdvancedSearch" ) {
   
<<lingo Filter/Hint>>
}

<div class="tc-search tc-advanced-search">
<$edit-text tiddler="$:/temp/advancedsearch" type="search" tag="input" focus={{$:/config/Search/AutoFocus}}/>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/AdvancedSearch/FilterButton]!has[draft.of]]"><$transclude/></$list>
</div>
This way I'd only see the text when the tag used is the original one. Is something like this possible?

The actual wikitext syntax for the above pseudo-code is:
<$list filter="[<currentTiddler>tag[$:/tags/AdvancedSearch]]">
   <
<lingo Filter/Hint>>
</$list>


Unfortunately, that won't achieve the results you want, as that tag will likely still be present, since you've *added* the $:/tags/SideBarSegment tag.

The solution is the recognize that in the $:/AdvancedSearch, the Filter tiddler appears *in a tab*, while as a SideBarSegment, it will be "stand-alone".  When a tiddler is shown in a tab, the <<tabs>> macro automatically defines a variable, <<currentTab>>, which is available from within each tiddler shown in that "tab set".

Thus, you could write the following:
<$list filter="[<currentTab>!match[]]">
   <
<lingo Filter/Hint>>
</$list>

This filter simply says "if you are not in a tab set, then show the lingo"

-e



Rafael Oliveira

unread,
Aug 4, 2020, 2:00:13 AM8/4/20
to tiddl...@googlegroups.com
Thanks Eric,

Now I feel that mastering the filter is what is required for creating more advanced macros...
Reply all
Reply to author
Forward
0 new messages