Search Results: Display field instead of title

Hi folks,
I successfully created a custom search which searches through some fields in a tiddler.
It is working and displays all tiddler titles as a search result. Since my tiddlers represent unique items, all tiddler titles are timetamps. This doesn’t look nice and I want to display at least one field or better: all searched fields as search results (instead of the titles list).
Is there an easy way to achieve this?
As ever, thank you in advance for any hints :slight_smile:

– Roland

Perhaps you can share your existing search filter(s)?

  • search:*[searchterm] will search all fields on the titles
1 Like

You can customize the way lists of results are displayed by altering either the template used by the list widget—see the custom item template section for an example—
or the contents of the list widget itself. For instance, if you always use a caption field, you could make a new template $:/Roland/ui/ListItemTemplate/caption with the following content, which will link to the proper tiddlers but use the caption for the link text, when available:

<div class="tc-menu-list-item"><$link><$text text={{{ [{!!title}get[caption]else{!!title}] }}} /></$link></div>

Before you start tinkering, though, I think you may be interested in @Eskha’s SmartSearch plugin—try searching the demo wiki to see how it works. In this case, the template being applied is $:/plugins/eskha/DelphesNotes/SmartSearch/template/result (though you’ll probably want the rest of the plugin, too, as it depends on a custom widget.)

1 Like

Thank you for your quick replies.

My search function looked like this:

Search: <$edit-text tiddler=<<currentTiddler>> field="MySearch"/>

<$set name="searchtest" value={{!!MySearch}} >
<$list filter="[{!!MySearch}length[]!match[0]]" variable="null">
<$list filter="[{!!MySearch}minlength[3]]" variable="null" emptyMessage="//Enter 3 characters at least//">

<$list filter="[!is[system]search:text,Description,Details{!!MySearch}]"  emptyMessage="No results"/>
</$list>
</$list>

<!--{{{ [{!!MySearch}length[]compare:number:gt[2]then{!!MySearch}else[Search text too short]] }}} -->

The missing link was the custom item template. Although I suspicted that I would need it (according to the List-Widget-Help) I wasn’t able to create a useful template for my needs.

Thank you very much, @etardiff, for providing this useful snippet, it helped me a lot :+1:
Your hint for Eshka’s SmartSearch plugin looks usefool, too. I will look into it for future extensions.

1 Like

Hello,

Just to let you now that I have just updated the SmartSearch plugin to provide a better sorting of results and fix some highlighting issues.

BR,

Eskha

3 Likes

Thank you! :+1:

–Roland