Skip to content

Content Items event handler: how to intercept the saving event of a Content Item? #15568

Answered by douwinga
MarGraz asked this question in Q&A
Discussion options

You must be logged in to vote

I think I missed your second question. Yes you can have event handlers on existing parts such as BagPart. Just do the same thing you would for a custom part public class MyBagPartHandler : ContentPartHandler<BagPart> and then in the startup services.AddContentPart<BagPart>().AddHandler<MyBagPartHandler>();. It may seem odd to be calling AddContentPart on a Part that has already been added, but if you look, this method calls GetOrAddContentPart, so you are not adding it twice.

Now that I think I understand what you are trying to do, this is probably the best approach and you can ignore the workflow idea. ContentPartHandlers can get the content item easily enough, so for some reason if you …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@douwinga
Comment options

Answer selected by MarGraz
@MarGraz
Comment options

@MarGraz
Comment options

@douwinga
Comment options

@MarGraz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants