London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
If you look at your variable e it has a property called Content. This is the content that is currently being saved.
Try casting it to ILocalizable and you can see which Language it is published in.
private void PublishContent(object sender, ContentEventArgs e) { var localizable = e.Content as ILocalizable; if (localizable == null) return; CultureInfo currentLanguage = localizable.Language; }
I have a custom function which is called on publish, similar to this article.
public class EventInitializationModule : IInitializableModule { public void Initialize(InitializationEngine context) { var contentEvents = ServiceLocator.Current.GetInstance();
contentEvents.PublishingContent += PublishContent;
}
void PublishContent(object sender, ContentEventArgs e)
{
myClass c = new myClass();
c.PublishEvent(sender, e);
}
public void Uninitialize(InitializationEngine context)
{
var contentEvents = ServiceLocator.Current.GetInstance();
contentEvents.PublishingContent -= PublishContent;
}
}
When PublishContent is hit, it is being passed SaveContentEventArgs instead of the parent ContentEventArgs.
Inside myClass.PublishEvent() I want to be able to get the language of the content being published. Is this possible? All the documentation points to using ContentLanguageEventArgs but there seems to be no way to pass that type instead of SaveContentEventArgs.
Using EPiServer 9.8