How to not show one result if another is not empty

Submitted by marcv on Sun, 2009-05-03 04:52.Troubleshooting

What is the syntax to not show one result if the other one has a value in it (is not empty).
In our display template there are cases there the subject appears twice. This is because the original thread title and reply title are the same. Since we do not search reply titles that is just for display purposes. So if there is a hit on the thread title it shows both the real title and the title again as the "subject_for_display" only value too.
Here is the line:
${searchResult.highlight(doc,"subject")}${searchResult.highlight(doc,"subject_for_display")}
So what I need is an if statement where if the "subject" has a value in it and is not null/empty/blank then we do NOT show the "subject_for_display" part.
I'm knowledgeable in asp, php syntax but not this one (yet) and I don't have this setup on dev server as it is live so can't experiment hit or miss so if you can let me know if this can be done in template and how that would be perfect. thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Submitted by chris on Sun, 2009-05-03 07:26.

This is easy, you can use:

 <#if (doc.get("subject")?has_content)>
 <#else>
 </#if>

to conditionally choose content to display.

Submitted by marcv on Sun, 2009-05-03 17:14.

That worked. I had to edit on the server in an editor for some reason when doing this (I tried same earlier) it would give a blank page. Did same now and then when I did it in regular text editor on the .ftl file directly it worked. Something must have been putting garbage in or messing up the template when trying to edit that template from the browser.

thanks