I've created a custom search result page using the PnP Modern Search web parts v4. I'm using the list template and I have file icons displaying, but I'd like to change these to my own custom icon.
The default template shows:
<div class="template--listItem--result">
{{#if @root.properties.layoutProperties.showFileIcon}}
{{#contains "['STS_Site','STS_Web']" (slot item @root.slots.contentclass)}}
<pnp-iconfile class="template--listItem--icon" data-extension="{{slot item @root.slots.FileType}}" data-is-container="{{slot item @root.slots.IsFolder}}" data-image-url="{{item.SiteLogo}}" data-size="32" data-theme-variant="{{JSONstringify @root.theme}}"></pnp-iconfile>
{{else}}
<pnp-iconfile class="template--listItem--icon" data-extension="{{slot item @root.slots.FileType}}" data-is-container="{{slot item @root.slots.IsFolder}}" data-size="32" data-theme-variant="{{JSONstringify @root.theme}}"></pnp-iconfile>
{{/contains}}
{{/if}}
I attempted to change pnp-iconfile to pnp-img but this resulted in only displaying my image, without any of the other search result content (title, author, etc). Can someone please explain how I might change the icon?
Additionally, would it also be possible to use 2 icons, depending on a managed property? Would the below work, for example:
{{#if @root.properties.layoutProperties.showFileIcon}}
{{#contains 'TypeA' (slot item @root.slots.iconType)}}
<pnp-icon ~ first icon image - not sure what content to place here yet ~> </pnp-icon>
{{else}}
<pnp-icon ~ second icon image - not sure what content to place here yet ~> </pnp-icon>
{{/contains}}
{{/if}}
{{else}} <pnp-iconfile class="template--listItem--icon" data-extension="{{slot item @root.slots.FileType}}" data-is-container="{{slot item @root.slots.IsFolder}}" data-image-url="https://address-of-icon-file" data-size="32" data-theme-variant="{{JSONstringify @root.theme}}"></pnp-iconfile>