Icons in search results

How can I add tiddler icons to $:/core/ui/ListItemTemplate?

This is what I have tried.

<div class="tc-menu-list-item">
/* I have also tried these combinations with {{<currentTidddler!!icon}} */
<$image source="image-path/{{!!icon}}.png"/><$link />
{{!!icon}}<$link />
</div>
1 Like

Try

<$transclude tiddler={{!!icon}}/>

However, you may want to wrap that in a div or span and use css to control the width and height, having the img fit the div.

Ex. object-fit:contain;

Otherwise you may have various sized icons appear in your list.

btw, this is a great idea. I’d like to see icons in my search result lists. I’ll be looking into this. Thank you.

This wont work because the wikitext is not parsed, the widget only “see” a text string. You need to concatenate the string before passing it as an argument, e.g using a Filtered Transclusion :

<$image source={{{ image-path/[{!!icon}].png +[join[]] }}}/>

@clsturgeon Alternatively, you can also use the template tiddler used to display the icon in $:/core/ui/ViewTemplate/title :

{{||$:/core/ui/TiddlerIcon}}

Same result but a bit shorter to type :slight_smile:

1 Like

Here’s an example of what I’ve done.

image

    <$list filter="[all[tiddlers]subfilter{$:/state/subfilter}]">
        <$set name="status" filter="[all[current]subfilter{$:/state/fieldforstatus}]">
        <li>
          <$list filter="[all[current]filter<status>]">
            <$list filter="[all[current]!search:rrfield[Paper]]">
              <<HB4>> <$link to=<<currentTiddler>>><$view field=title/></$link>
            </$list>
            <$list filter="[all[current]search:rrfield[Paper]]">
              <span class="paperclass">
                <<HB4>> <$link to=<<currentTiddler>>><$view field=title/></$link>
              </span>
            </$list>
          </$list>
          <$list filter="[all[current]!filter<status>]">
            <$list filter="[all[current]!search:rrfield[Paper]]">
              <<HB0>> <$link to=<<currentTiddler>>><$view field=title/></$link>
            </$list>
            <$list filter="[all[current]search:rrfield[Paper]]">
              <span class="paperclass">
                <<HB0>> <$link to=<<currentTiddler>>><$view field=title/></$link>
              </span>
            </$list>
          </$list>
        </li>
      </$set>
    </$list>

This uses the Harvey Balls plugin of telmiger. I use them as status indicators.