So I'm intercepting the event when the user saves an Item in the back office, the main reason I am doing this is to set default images if the user does not enter one, this is working great so far.
However I have just added another document type that has an Archetype Property one of those properties is an image.
How can I do this for Archetype?
This is what I have done so far, the regular documents work fine.
private void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e)
{
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var defaultValues = umbracoHelper.GetDefaultValues();
foreach (var content in e.SavedEntities.Where(c => c.ContentType.Alias == "scholar" || c.ContentType.Alias == "newsPost" || c.ContentType.Alias == "eventItem" || c.ContentType.Alias == "eventSpeaker" || c.ContentType.Alias == "podcastGroup"))
{
if (content.HasProperty("profilePicture") && string.IsNullOrWhiteSpace(content.GetValue<string>("profilePicture")))
{
content.SetValue("profilePicture", defaultValues.GetProperty("defaultScholarProfileImage").Value);
sender.Save(content);
}
if (content.HasProperty("listingImage") && string.IsNullOrWhiteSpace(content.GetValue<string>("listingImage")))
{
content.SetValue("listingImage", defaultValues.GetProperty("defaultNewsListingImage").Value);
sender.Save(content);
}
if (content.HasProperty("podcastFiles") && content.GetValue<ArchetypeModel>("podcastFiles").Count() > 1)
{
foreach (var podCastFile in content.GetValue<ArchetypeModel>("podcastFiles"))
{
if (!podCastFile.HasValue("image"))
{
podCastFile. //What do I do here?
}
}
content.SetValue(WHAT-DO-I-DO-HERE, defaultValues.GetProperty("defaultPodCastImage").Value); //And Here
sender.Save(content);
}
}
Archetype - Programmatic Manipulating Values
Hi Guys,
I have added some code to the Umbraco Event
So I'm intercepting the event when the user saves an Item in the back office, the main reason I am doing this is to set default images if the user does not enter one, this is working great so far.
However I have just added another document type that has an Archetype Property one of those properties is an image.
How can I do this for Archetype?
This is what I have done so far, the regular documents work fine.
}
I have the same problem with you. Have you solve it ? Can you share me a tip ?
is working on a reply...