Can the search results on the member search page be sorted by an ExtendedAttributes or ProfileFields field?
Can the search results on the member search page be sorted by an ExtendedAttributes or ProfileFields field?
This is my first attempt at a widget extension using the in-process API, but it doesn't seem to return any results after the sorting:
The widget extension C# code:
using Telligent.Evolution.Extensibility.UI.Version1;
using Telligent.Evolution.Extensibility.Api.Entities.Version1;
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
namespace Utils
{
public class Utilities
{
public string Base64Encode(string base64Decoded)
{
byte[] data = ASCIIEncoding.ASCII.GetBytes(base64Decoded);
string base64Encoded = Convert.ToBase64String(data);
return base64Encoded;
}
public string ConvertTimestamp(int ts)
{
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(ts).ToLocalTime();
return dt.ToString("MMM dd, yyyy");
}
public List<SearchResult> SortSearchResults(List<SearchResult> ls)
{
List<SearchResult> SortedList = ls.OrderBy(o => o.Users[0].ExtendedAttributes["SortOrder"]).ToList();
return SortedList;
}
}
public class UtilsWidgetExtension : IScriptedContentFragmentExtension
{
#region IScriptedContentFragmentExtension Members
public string ExtensionName
{
get { return "Ibby_v1_Utils"; }
}
public object Extension
{
get { return new Utilities(); }
}
#endregion
#region IPlugin Members
public string Name
{
get { return "Utilities"; }
}
public string Description
{
get { return "Utilities"; }
}
public void Initialize()
{
}
#endregion
}
}
The Velocity code:
#set ($searchResultsOriginal = $core_v2_searchResult.List($searchListOptions)) #set($searchResults = $Ibby_v1_Utils.SortSearchResults($searchResultsOriginal)) ## Render Search Results #set ($hasMore = false) #set ($currentPagedQuantity = ($searchResults.PageIndex + 1) * $searchResults.PageSize) #if ($searchResults.TotalCount > $currentPagedQuantity) #set ($hasMore = true) #end
What could the problem be?
Have you tried debugging and stepping through to confirm that the method is called and the fields you are using to sort compare are there?