I've created a custom Sharepoint Search Result page using a list template, and I've added a line at the bottom of each result that shows Category: URL
The URL is obtained from a custom column that is a managed property, which I've added into my Slots layout. Not every result will have a URL listed in the custom column. In those instances it shows Category: and then a blank space. What I would like to do is completely hide the category line, if the result has no value in the column.
I tried using the following:
{{#if @root.slots.CategoryURL}}
<div><b>Category: </b><a href="{{slot item @root.slots.CategoryURL}}"><i>{{slot item @root.slots.Summary}}</i></a></div>
{{/if}}
but all results still show the category line.
I also tried:
{{#if @root.slots.CategoryURL !=""}}
<div><b>Category: </b><a href="{{slot item @root.slots.CategoryURL}}"><i>{{slot item @root.slots.Summary}}</i></a></div>
{{/if}}
but this causes the web part to not display any results anymore.
How can I hide this line based on whether the column has data for that particular returned search result item?
{{#if slot item @root.slots.CategoryURL}} <div><b>Category: </b><a href="{{slot item @root.slots.CategoryURL}}"><i>{{slot item @root.slots.Summary}}</i></a></div> {{/if}}
isdefined
) like shown here: handlebarsjs.com/guide/builtin-helpers.html#sub-expressions{{#if (isdefined slot item @root.slots.CategoryURL)}} <div><b>Category: </b><a href="{{slot item @root.slots.CategoryURL}}"><i>{{slot item @root.slots.Summary}}</i></a></div> {{/if}}
but this also gave no results