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?
I've attempted to write some code for this. Would this work as a widget extension?
public class MyUsers
{
public Telligent.Evolution.Extensibility.Api.Entities.Version1.SearchResults GetUsers(int pageIndex, int pageSize, string filters, string query)
{
ISearchResults search = Apis.Get<ISearchResults>();
var searchOptions = new SearchResultsListOptions
{
PageIndex = pageIndex,
PageSize = pageSize,
Query = query,
Filters = filters
};
searchOptions.Sort = "UserSortOrder";
var results = search.List(searchOptions);
return results; //Apis.Get<Users>().List(options);
}
public void BeforeSearchBulkIndexingEventHandler(BeforeBulkIndexingEventArgs e)
{
SearchIndexDocument d = new SearchIndexDocument();
d.AddField("UserSortOrder", GetSortOrder(d.ContentId));
e.Documents.Append(d);
}
private string GetSortOrder(Guid contentId)
{
SqlDataAccess sd = new SqlDataAccess();
using (SqlCommand cmd = sd.GetCommand("ibby_UserSortOrder_Get"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ContentId", contentId);
DataTable dt = sd.Execute(cmd);
if (dt.Rows.Count > 0)
return dt.Rows[0]["UserSortOrder"].ToString();
else
return string.Empty;
}
}
}You are not longer writing a widget extension. You are writing a plugin and possibly modifying widget code.