TLDR: I'd like to know every content node used in the current mapping operation, but I only have access to the most nested content node. Longer explanation below.
I map my typical page model like this:
var page = CurrentPage.As<Typical>();
My typical page model looks like this:
public class Typical
{
[DittoMixedArchetype]
public IEnumerable<IWidget> MainContent { get; set; }
}
One of my widgets, LocationBanner, looks like this:
public class LocationBanner : Widget
{
public string Header { get; set; }
public string Address { get; set; }
public string PhoneNumber { get; set; }
[DittoOnConverted]
public void Converted(DittoConversionHandlerContext context)
{
// This is the ArchetypePublishedContent, which implements IPublishedContent.
var content = context.Content;
// This is the current instance of LocationBanner.
var model = context.Model;
// This is typeof(LocationBanner).
var modelType = context.ModelType;
// The context does not actually contain the Location content node.
}
}
The comments above note all the properties the context gives me (i.e., content, model, and model type). What the context does not have is the current Location page that contains the LocationBanner widget.
Sure, in this instance, I can just get the current Location page from global::Umbraco.Web.UmbracoContext.Current.PublishedContentRequest.PublishedContent. However, had I used my concept of a "picked widget" (basically, an Archetype fieldset that contains a multinode tree picker property that picks another content node that contains an Archetype property that contains widgets), this would not work, as the current page would not be the page in which the Archetype fieldset resides.
I'm wondering if the DittoConversionHandlerContext should contain a stack of contextual information, such as the list of content nodes used in each mapping operation. That way, I could look through the content nodes for the first one that contains location information (e.g., so I can populate the address shown in the above LocationBanner class).
One way of implementing this would be to give the DittoConversionHandlerContext class a Parent property that refers to the previous DittoConversionHandlerContext instance.
Is that something you would consider implementing as part of Ditto?
Conversion Context Lost in Nested Models
TLDR: I'd like to know every content node used in the current mapping operation, but I only have access to the most nested content node. Longer explanation below.
I map my typical page model like this:
My typical page model looks like this:
One of my widgets,
LocationBanner
, looks like this:The comments above note all the properties the context gives me (i.e., content, model, and model type). What the context does not have is the current
Location
page that contains theLocationBanner
widget.Sure, in this instance, I can just get the current
Location
page fromglobal::Umbraco.Web.UmbracoContext.Current.PublishedContentRequest.PublishedContent
. However, had I used my concept of a "picked widget" (basically, an Archetype fieldset that contains a multinode tree picker property that picks another content node that contains an Archetype property that contains widgets), this would not work, as the current page would not be the page in which the Archetype fieldset resides.I'm wondering if the
DittoConversionHandlerContext
should contain a stack of contextual information, such as the list of content nodes used in each mapping operation. That way, I could look through the content nodes for the first one that contains location information (e.g., so I can populate the address shown in the aboveLocationBanner
class).One way of implementing this would be to give the
DittoConversionHandlerContext
class aParent
property that refers to the previousDittoConversionHandlerContext
instance.Is that something you would consider implementing as part of Ditto?
is working on a reply...