Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Smart search count View modes: 
User avatar
Certified Developer 8
Certified Developer 8
richard - 8/20/2013 1:01:38 PM
   
Smart search count
Hi this article says that you can get the result count from a Smart search by using <%# Eval("Pages") %> but this does not appear to work (7.0).

Has this changed since this FAQ was written?

Cheers

Richard

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 8/20/2013 2:19:27 PM
   
RE:Smart search count
Hello Richard,

I'm sorry, I don't know how old is that FAQ article but here is the working example (and I believe you can find more just by searching the forums as first)...

For showing the total number of the search results, please open ~\CMSModules\SmartSearch\Controls\SearchResults.ascx.cs and there find this code:
// Search
DataSet results = SearchHelper.Search(parameters);

int numberOfResults = parameters.NumberOfResults;

if ((MaxResults > 0) && (numberOfResults > MaxResults))
{
numberOfResults = MaxResults;
}

Below these lines of code please put:
// Show now results found ?
if (numberOfResults == 0)
{
lblNoResults.Text = NoResultsText;
lblNoResults.Visible = true;
}
// this is custom clause
else
{
lblNoResults.Text = numberOfResults.ToString();
lblNoResults.Visible = true;
}

RequestStockHelper.Add("totalNumber", lblNoResults.Text);

And now go to CMS Desk and to the properties of your search web part and open the transformation, in that transformation put:
<%# IfCompare(DataItemIndex,0, "", RequestStockHelper.GetItem("totalNumber")) %>

After you do this, you should see the total number of results..

Best Regards,
Martin Danko

User avatar
Certified Developer 8
Certified Developer 8
richard - 8/20/2013 4:15:23 PM
   
RE:Smart search count
Awesome thanks for your quick reply Martin

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 8/20/2013 5:17:14 PM
   
RE:Smart search count
Hi Richard,

I'm glad that it works, you're welcome!

Best Regards,
Martin Danko