I stumpled upon this service while searching on the net - it really fulfill my needs - short story long: I use the ImageCropper one of my doctypes. Every time I publish a noce of that doctype I would like to generade a list of all the crops associated to the cropper - I do this by using this ContentService http://our.umbraco.org/documentation/reference/events-v6/ContentService-Events
My Code looks like this:
using System; using System.IO; using Umbraco.Core; using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Publishing; using Umbraco.Core.Services; using umbraco.cms.businesslogic.web; namespace My.WebSite { public class createIcons : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { ContentService.Published += ContentServicePublished; }
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args) { foreach (var node in args.PublishedEntities) { if (node.ContentType.Alias == "RadioChannel" || node.ContentType.Alias == "Podcast") { var fileName = String.Format("{0}test.txt", AppDomain.CurrentDomain.BaseDirectory);
using (StreamWriter writer = new StreamWriter(fileName)) { var doc = new Document(node.Id); var icon = doc.getProperty("PlayerIcon").Value; writer.Write("{0}", node.Name + " - " + node.Id + " - " + icon); } } } } } }
Access all crops in ContentService
Hi,
I stumpled upon this service while searching on the net - it really fulfill my needs - short story long: I use the ImageCropper one of my doctypes. Every time I publish a noce of that doctype I would like to generade a list of all the crops associated to the cropper - I do this by using this ContentService http://our.umbraco.org/documentation/reference/events-v6/ContentService-Events
My Code looks like this:
test.txt looks like this:
The documentation says I can iterate through the crops - but How do I do this in a ContentService?
Hi Robin,
I'm not 100% on what you are doing, do you want to use GetCropUrl with IContent or just iterate the crops?
I do a ton of stuff with the setting the ImageCropper values in my Crop Healer package, so you might find something useful in here
Jeavon
is working on a reply...