Hi,
I'm really glad to hear that you've found the CMS useful! Always interesting to hear how it's being used, thank you.
Regarding your question there's a couple of possible answers (a little depending on how you want it to work).
When a new page is created in the editor the current node of the page tree is refreshed and repopulated with the child pages, including the newly created one. So what you should see is always a reflection of the sort order.
When the parent have a sort order set to SortIndex newly created pages will get the index 0 until they are manually reordered within the page tree, thus ending up first in the list.
Option 1) is to change the sort order to alphabetical or based on creation date. The default settings will only be applied to new pages created after it has been set, for pages already existing it has to be done by expanding "+ Show advanced options" when editing the parent page and changing the value:
Option 2) If you want to keep the ability to manually reorder children (which you loose if you chose to sort by anything other than "Sort index") you could add a bit of code to the save event to change the index value.
This is done by attaching an event handler to the page factory:
PageFactory.PageSaved += PageSavedHandler;
In the event handler you can then change the sort index like this:
private void PageSavedHandler(object sender, KalikoCMS.Events.PageEventArgs e) {
var page = e.Page;
// Only run for the first version of the page
if(page.CurrentVersion == 1) {
// Get the number of siblings and calculate the last possible position
var siblings = PageFactory.GetChildrenForPage(page.ParentId, KalikoCMS.Core.PublishState.All);
var lastPosition = siblings.Count - 1;
// If there are more siblings...
if(lastPosition > 0) {
// ...move our saved page to the last position
PageFactory.ReorderChildren(page.PageId, page.ParentId, lastPosition);
}
}
}
Notice that the sort index must be in the range of 0 to number of children - 1 otherwise it will fail.
It might also need a bit more logic (like checking if it's a particular content type etc.), but I hope it can serve as an example of what can be done.