Essentially, I'm attaching to the publishing event like so
contentEvents.PublishedContent += MyMethodOnPublish;
then eventually saving my content like so
contentRepository.Save(editablePage, SaveAction.ForceCurrentVersion, AccessLevel.NoAccess);
but then the event for the content keeps getting called in an infinite loop, which kinda makes sense but obviously is not the desired behaviour, is there a recommended method to prevent this publishing loop?
using CMS 188.8.131.52
You don't need to save the content inside the event handler.
If you make any changes to the content being published, it will be saved right after your event handler. Unless you cancel the action, of course.
To be more cleare on what Stefan says,
You need attach to contentEvents.PublishingContent instead of contentEvents.PublishedContent
Then you can change the content, and don't need to call the save method again.
Thank you @Stefan and @Sebbe, yeah Stefan was mostly correct, except if using Published (instead of Publishing) then it complains about the properties being read-only.