Try our conversational search powered by Generative AI!

Get value of context=epi.cms.contentdata

Vote:
 

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.

#231547
Dec 01, 2020 12:11
Vote:
 

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()

#232694
Dec 02, 2020 11:26
Vote:
 

Hi Bartosz,

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 :)

#232999
Dec 03, 2020 8:42
Vote:
 

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.

#234848
Edited, Dec 03, 2020 10:26
Vote:
 

Thank you so much for that, looking forward hearing from you! :)

#234849
Dec 03, 2020 10:58
Vote:
 

It took a while but a solution is coming.

Solution would be available in CMS UI 11.36.2

Stay tuned!

Available here: https://nuget.optimizely.com/package/?id=EPiServer.CMS.UI&v=12.0.2

#263163
Edited, Sep 15, 2021 11:11
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.