Hi!
I know its possible to modify but I cant any information about it. When creating a new page in the CMS the page should be created first and not last in the list of pages.
Litium version: 6.3.7
Hi!
I know its possible to modify but I cant any information about it. When creating a new page in the CMS the page should be created first and not last in the list of pages.
Litium version: 6.3.7
I solved it myself.
public EventHandlerStartup()
{
ModuleCMS.Instance.EventManager.PageCreated += EventManagerOnPageEvent;
}
private void EventManagerOnPageEvent(Guid webSiteId, Guid pageId, Guid parentPageId)
{
var token = ModuleCMS.Instance.AdminToken;
var currentPage = Page.GetFromID(pageId, token);
var parentPage = currentPage.GetParentPage(token);
try
{
currentPage.Move(parentPage, 0, token);
}
catch(Exception e)
{
Solution.Instance.Log.CreateLogEntry("PageCreated could not be added first", e, LogLevels.ERROR);
}
}
To think on is that in a multiserver setup the PageCreated
event will be fired in every node, this move-command without synchronization between node may fail in some nodes that will reflect in false-positive error-logs.
@patric.forsgard Do you have any recomendations? Or should I just nog log anything?
Some alternatives can be:
Can’t you just have a startuptask with the event handler that is set to only run on one machine?
Yes, you can. But if that machine is down for maintenance or upgrade and not catching that event the page will still be in the bottom of the list.
Thanks!
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.