Try our conversational search powered by Generative AI!

Custom sorting in CMS interface

Vote:
 

Hello fellas!

I have created a automatic map structure for a pagetype called news through a event listner. The structure is based on (Type/year/month/news). However I have problems solving the sorting for the month folders. I want it to be sorted by month (January, February, Mars etc), in the picture you can see the news containers are in the wrong order. I discovered there is built in functions for sorting by created date and alfaphatic order. But I haven't found anything for custom sorting. I have added a field in the NewsContainers for the sort order. Do someone know how to handle custom sorting? Let me know if I need to provide more info.



NewsContainer:

#310767
Edited, Oct 13, 2023 6:18
Vote:
 

Hi,

On the year containers, you can set to sort children by index instead of publish date etc. Then on each month container you set a sort index.

For the year container:

public override void SetDefaultValues(ContentType contentType)
{
    base.SetDefaultValues(contentType);

    // First evauluate if this is year container, then set this property
    ChildSortOrder = FilterSortOrder.Index;
}

For month:

public override void SetDefaultValues(ContentType contentType)
{
    base.SetDefaultValues(contentType);

    int month = GetMonth(); 
    SortIndex = month;
}

Adjust the month value to sort ascending or descending. Index will always sort by ascending.

#310777
Edited, Oct 13, 2023 10:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.