Before using V6 I had some C# code (in the Document.AfterSave event handler) to move a node to a parent node according to the date month. This is the code that I used:
Hmm I'm doing the exactly same thing but that works fine for me. Apart your code I've attached to the new event handlers of the ContentService. Thats the only difference... there is no need to call the .Save() method.
Is it perhaps only an UI problem and you need to reload the nodes? There is a new client script for this purpose:
...but the SortOrder isn't being set, it just defaults to the index of the node - but I want to order it according to it's negative month number (eg. August = -8). Do I need to add any other code to set the SortOrder?
I think the problem is that you only set the sort numberof your current month node which has no relation to the sort numbers of any other month nodes. I'm using the following snippet to re-order all month nodes after a new one was created:
Thanks for that, I was originally trying to order them in reverse direction, but I don't think you can use negative sort numbers anymore? Anyway it's probably better having them order ascending (the .OrderByDescending(f => f.Name) method doesn't exist by the looks of it?), and your code works perfectly so thanks for your help.
ContentService.Move not moving a node
Before using V6 I had some C# code (in the Document.AfterSave event handler) to move a node to a parent node according to the date month. This is the code that I used:
Now with V6 I'm trying to do the same thing:
But this doesn't seem to move the node. Am I missing something?
Perhaps there is a .Save() method you need to call before it's done? Otherwise you can report an issue here: http://issues.umbraco.org/issues#newissue=yes
Jeroen
Hmm I'm doing the exactly same thing but that works fine for me. Apart your code I've attached to the new event handlers of the ContentService. Thats the only difference... there is no need to call the .Save() method.
Is it perhaps only an UI problem and you need to reload the nodes? There is a new client script for this purpose:
Thanks for the replies, I've got it working now, I think the problem may have been that the event handler was using legacy code:
So I've now completely updated all code to use the new API, eg:
Now I'm creating a month folder node, and I'm having trouble setting the SortOrder. Here's the code:
...but the SortOrder isn't being set, it just defaults to the index of the node - but I want to order it according to it's negative month number (eg. August = -8). Do I need to add any other code to set the SortOrder?
I think the problem is that you only set the sort numberof your current month node which has no relation to the sort numbers of any other month nodes. I'm using the following snippet to re-order all month nodes after a new one was created:
That works fine :)
Just for your information: my month nodes all starts with 01 - january, 02 february and so on.
Thanks for that, I was originally trying to order them in reverse direction, but I don't think you can use negative sort numbers anymore? Anyway it's probably better having them order ascending (the .OrderByDescending(f => f.Name) method doesn't exist by the looks of it?), and your code works perfectly so thanks for your help.
is working on a reply...