I'm using the Examine search on my Umbraco 7.1.4 site. The search is working fiine and is returning results. I'm wanting to know how I can display a message when there are no results in the resultset.
Apologies for the silly question but I thought it would just be a case of checking for type or length, so far everything I have tried has not worked.
foreach (var result in Umbraco.TypedSearch(Request.QueryString["q"]))
I think if you store the search results in a variable then you can check that before you try iterate or output your 'no results' if it's empty. As you have it, it will not enter the foreach if there are no results.
for example:
var results = Umbraco.TypedSearch(Request.QueryString["q"]))
Umbraco.TypedSearch handle empty resultset
Hi There,
I'm using the Examine search on my Umbraco 7.1.4 site. The search is working fiine and is returning results. I'm wanting to know how I can display a message when there are no results in the resultset.
Apologies for the silly question but I thought it would just be a case of checking for type or length, so far everything I have tried has not worked.
foreach (var result in Umbraco.TypedSearch(Request.QueryString["q"]))
{
if (result.GetType().ToString() == " ")
{
<section class="section">
<div class="row col-span-12">
<h3>No results found</h3>
</div>
</section>
return;
}
}
Hi
I think if you store the search results in a variable then you can check that before you try iterate or output your 'no results' if it's empty. As you have it, it will not enter the foreach if there are no results.
for example:
cheers
thank you ! Works great.
is working on a reply...