Another option Brenden, is to add Categories to the Smart Search index, and then use a Smart Search Text Filter webpart on it (coupled with some javascript to write the write filter text in it).
1st: Either create a duplicate Smart Search results that returns the result's categories, or add a hidden input tag with the categories values so you can (through javascript) gather all the categories in the returned results.
2: Use that list to build a Option List with the categories that were in the results
3: On "Search" Grab the values from the drop down, and then popoulate the hidden Smart Search Text field as such:
Categories:("FirstCategory" "SecondCategory" "Etc")
You can add a + or - to the Categories to enforce it has to or simply to weigh higher if it does.
To add Category Names to the Smart Search, use the below code:
using CMS.Base;
using CMS.DocumentEngine;
using CMS.Membership;
using System.Collections.Generic;
[SmartSearchContentLoader]
public partial class CMSModuleLoader
{
/// <summary>
/// Attribute class for assigning event handlers.
/// </summary>
private class SmartSearchContentLoaderAttribute : CMSLoaderAttribute
{
/// <summary>
/// Called automatically when the application starts.
/// </summary>
public override void Init()
{
// Assigns a handler to the GetContent event for pages
DocumentEvents.GetContent.Execute += OnGetPageContent;
}
private void OnGetPageContent(object sender, DocumentSearchEventArgs e)
{
// Gets an object representing the page that is being indexed
TreeNode indexedPage = e.Node;
// Checks that the page exists
if (indexedPage != null)
{
// Add category names to a searchable field "Categories" for filtering / weighing.
List<string> joinedCategories = new List<string>();
foreach (CMS.Taxonomy.CategoryInfo cat in e.Node.Categories)
{
joinedCategories.Add(cat.CategoryName);
}
e.SearchDocument.AddGeneralField("Categories", string.Join("|", joinedCategories.ToArray()), true, true);
// Gets the user object of the page owner
UserInfo pageOwner = UserInfoProvider.GetUserInfo(indexedPage.NodeOwner);
if (pageOwner != null)
{
// Adds the value of the "Description" field from the owner's user settings into the indexed content
// Spaces added as separators to ensure that typical search index analyzers can correctly tokenize the index content
//e.Content += " " + pageOwner.UserDescription + " ";
}
}
}
}
}