Currently the code available in Core module help us to include sorting parameter for brokery query as shown below. This implementation has option to include Meta key for Metadata field. But i need to include for Contentdata field.
//Adding sort parameter to the Query
query.AddSorting(GetSortParameter());
private SortParameter GetSortParameter()
{
SortDirection dir = _queryParameters.Sort.ToLower().EndsWith("asc") ? SortParameter.Ascending : SortParameter.Descending;
return new SortParameter(GetSortColumn(), dir);
}
private SortColumn GetSortColumn()
{
//TODO add more options if required
int pos = _queryParameters.Sort.Trim().IndexOf(" ", StringComparison.Ordinal);
string sort = pos > 0 ? _queryParameters.Sort.Trim().Substring(0, pos) : _queryParameters.Sort.Trim();
switch (sort.ToLower())
{
case "title":
return SortParameter.ItemTitle;
case "pubdate":
return SortParameter.ItemLastPublishedDate;
default:
//Default is to assume that its a custom metadata date field;
return new CustomMetaKeyColumn(_queryParameters.Sort, MetadataType.DATE);
}
}
I want to create a Sort Column to query Content field "date" or "year" or "location" which is included in Content part of the News Article/Product Component.