Refinements are a welcome addition to the Search/Query capabilities in the default SharePoint 2010 user interface. I remember that most of our SharePoint 2007 projects that involved some search results customization have been implemented relying on the Faceted Search project (still available on CodePlex) or on some commercial tolls (Ontolica, now Surfray, being one of those).
The way refinement panels work is somewhat complicated, as it entails server components (aka filter generators), server controls (OOTB) as well as some XSLT tricks that you can use to customize the refinement UI.
One of these tricks determines how the “Show More Links” feature is realized.
You need the help of the filter generator in order to discriminate between “visible” links and links that are instead hidden, waiting for an explicit request by the user.
The filter generator returns a bunch of XML markup, where you may have two sections (two elements) that contain either “top results” and “all results” (the threshold is typically defined by a property of the generator instance).
You may end-up with something like this [most of the code has been omitted]:
XmlElement element = filterXml.CreateElement("FilterCategory");
XmlElement topElements = filterXml.CreateElement("Filters");
XmlElement moreElements = filterXml.CreateElement("MoreFilters");
Of course, most of the hard work is done by the logics of the refinement filter generator.
But… there’s something that is up to you – the site builder – which is of course the presentation of these aggregations.
OOTB, SharePoint 2010 comes with some XSLT that probably fits most of your needs.
But this may not be enough when, for example, you have developed a custom filter generator (or you have downloaded or bought one) and you need to make it available.
The example I’m bringing to your attention, and which of course gives the title to this post, is related to the way the OOTB XSLT renders the “All Results” fragment.
Just take a look and try to find-out what I’m talking about:
<xsl:variable name="MoreFilters" select="MoreFilters/Filter" />
<xsl:when test="$FilterCategoryId and ($FilterCategoryId != ”) and ($FilterCategoryType = ‘Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator’)">
<xsl:when test="$FilterCategoryId and ($FilterCategoryId != ”) and ($FilterCategoryType = ‘Microsoft.Office.Server.Search.WebControls.TaxonomyFilterGenerator’)">…
The OOTB XSLT template applies (and then renders) the “All Results” section differently according to the type (the .NET Type) of the refinement filter generator. In the above snippet, there’s a “choose/when” statement (the equivalent of the “switch/case” or “Select/Case” syntax construct you may be familiar with) that is there exactly for this purpose.
Needless to say that, if you need to render links also for refinement panels based on your custom generator, you also need to update the XSLT transformation accordingly:
<xsl:when test="$FilterCategoryId and ($FilterCategoryId != ”) and ($FilterCategoryType = ‘GreenTeam.SharePoint2010.EnterpriseSearch.MultiValueFilterGenerator, GreenTeam.SharePoint2010.EnterpriseSearch, Version=184.108.40.206, Culture=neutral,PublicKeyToken=7b398aba874a4ea9’)">