Hi,I would like to get hold of this value in OnContentCreating event.Here is the scenario.
User is in editing context of a block that has a content area. Their workflow is that they want to create article page that would become content area item of block being edited.
If user clicks on '+' button and choses New Page, user gets a list of all pages available. User can chose Article page, user can fill out properties and still url part would be 13643 in my case all the way throgh until actually clicking on the Create button. At that moment context changes to the newly crated page.
Is there a way of geting that epi.cms.contentdata value in OnContentCreating event so that, while creating and checking if that one specific block type is in question, I could add content area item with the reference of 13643 in my case? If not is there a way of knowing from which context OnContentCreating event got called?What I need is, as a matter of fact, opposite of PageEdititng.GetEditUrl(reference) if even possible to get hold of in that event.
This is not possible at the moment.
The event arg that you have in ContentCreating even is unaware of the context that initiated the action.
There are two ways to proceed.
1) You can hook to CreateContent and CreateContentViewModel save methods on your side, get the context and call your custom endpoint that runs custom logic
2) We solve it as a feature in epi - each call initiated from the Edit Mode is context-aware so that in every event like ContentCreating, ContentPublished etc you can somehow get to that context, either by the event arg directly or via a custom abstraction like IContextResolver.Resolve()
unless your first approach is not something from dojo this is something I already tried before posting this question
public void Initialize(InitializationEngine context)
context.Locate.ContentEvents().CreatedContent += CreatedContent;
context.Locate.ContentEvents().CreatingContent += CreatingContent;
but in both cases e.Content either have the newly created contentLink (not the one that I was looking for) or it's an empty contentReference.
This second approach would be nice to have :)
Yeah, the 1st approach was dojo. From your reaction I assume you don't want to have anything to do with dojo :)
I will try to create a PoC for the 2nd approach today and get team's opinion. Will post back soon.
Thank you so much for that, looking forward hearing from you! :)
It took a while but a solution is coming.
Solution would be available in CMS UI 11.36.2
Available here: https://nuget.optimizely.com/package/?id=EPiServer.CMS.UI&v=12.0.2