November Happy Hour will be moved to Thursday December 5th.

Current content for PropertyList item selection factory

Ted
Ted
Vote:
 

When attaching a SelectOne or SelectMany attribute to a POCO object property being edited as part of a PropertyList property, the ExtendedMetadata object only contains the POCO object. The Model property is null, and it seems there's no way of getting the current content being edited, i.e. the current IContent object.

public IEnumerable GetSelections(ExtendedMetadata metadata)
{
        var currentContent = metadata.FindOwnerContent(); // This is null
}

I briefly had an idea of getting the current content by parsing the URL, but since the URL is for the selection factory store, that doesn't help me much - that URL doesn't contain any information about the current content context.

Any bright ideas? :)

#143346
Jan 20, 2016 23:23
Vote:
 

That is basically what is done in the FindOwnerContent method. I don't think it works for PropertyList

#143350
Jan 21, 2016 10:22
Ted
Vote:
 

Thanks, Marija! I'm not sure that works, though?

It would normally, but when editing a PropertyList item (i.e. a POCO object) the selection factory REST store request simply includes the name of the selection factory type - there is no content context information.

That code sample could be replaced with the FindOwnerContent extension method, but regardless I still get null back. :/

Edit: Right, like Per said. :)

#143351
Edited, Jan 21, 2016 10:23
Vote:
 

Hi!

Old thread, I know! But... did you ever find a soloution for this? I'm running into the same problem :)

#187452
Jan 23, 2018 11:32
Vote:
 

If you have latest version of Epi and it still doesn't, it sounds like it should be reported as a bug to Episerver support. I couldn't find a bug report, see this.

#187453
Jan 23, 2018 11:51
Vote:
 

I got this answer from Episerver today 2018-06-19

"We're developing a story that will fix this issue. The story will be released in CMS UI 12 that requires some breaking changes."

#194307
Jun 19, 2018 10:49
sp
Vote:
 

I'm into the same problem. Is there any alternative solution to it? 

#254486
May 07, 2021 11:36
Praful Jangid - May 10, 2021 12:36
What is your CMS UI version?
sp - May 10, 2021 13:25
Hi Praful, Thanks for your response. I'm using EPiServer.CMS.UI - 11.30.0.
Vote:
 

OK, I managed to fix this.
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

#263161
Edited, Sep 15, 2021 11:10
- Aug 30, 2022 11:09
So how did you fix this? There is no CMS UI 11.36.2, and 11.36.10 does not do anything to resolve this. Also, your link points to version 12.0.2 of CMS UI, which is running .net core and is not compatible with EPI 11 projects.
Vote:
 

For the property edit mode on a block, current contentlink can be retrieved from like so in the GetSelection method:

var currentContentLink = EPiServer.Core.ContentReference.Parse(HttpContext.Current.Request.Headers["x-epicurrentcontentcontext"]);

This however will not work in the quick-edit dialog, the x-epicurrentcontentcontext header will there instead contain whatever content you were on before opening the quick-edit dialog.

#286365
Aug 30, 2022 12:11
* 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.