Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have the following code which I hoped would force all Folder media items to appear first in their list.
public class CreateEvent : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase a, ApplicationContext c) { MediaService.Creating += MediaService_Creating; } void MediaService_Creating(IMediaService sender, NewEventArgs<IMedia> e) { if (e.Entity.ContentType.Alias.EndsWith("Folder")) { e.Entity.SortOrder = 0; } } }
Unfortunately, Umbraco seems to ignore the value I am setting. Presumably because it is working out the SortOrder after this event is fired.
Any ideas how I can overcome this? Ideally, I would like to be able to set the SortOrder and not then have to reload the content tree :)
You could try one of the events that fires after the creation is complete maybe? Try MediaService.Created instead and see if that works.
Yeah I've tried that too. I'm surprised there isn't an obvious means to do this. Time to go to the source ...
Did you find a solution?
I'm having the same problem with the contentservice.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Saving the SortOrder using MediaService.Creating
I have the following code which I hoped would force all Folder media items to appear first in their list.
Unfortunately, Umbraco seems to ignore the value I am setting. Presumably because it is working out the SortOrder after this event is fired.
Any ideas how I can overcome this? Ideally, I would like to be able to set the SortOrder and not then have to reload the content tree :)
You could try one of the events that fires after the creation is complete maybe? Try MediaService.Created instead and see if that works.
Yeah I've tried that too. I'm surprised there isn't an obvious means to do this. Time to go to the source ...
Did you find a solution?
I'm having the same problem with the contentservice.
is working on a reply...