Wondering how Ditto handles composite Document Types?
For the example below, would you create 2 pocos?
Article
Attributes on Document Type
Include Meta
Meta
Meta (tab) [900]
metaTitle: Title (Textstring)
metaDescription: Description (Textstring)
socialTitle: Social Title (Textstring)
socialDescription: Social Description (Textstring)
socialImage: Social Image (Media Picker)
Something like:
namespace Undiscovered.Site.Logic.Model.Content
{
using Composite;
public class Home
{
public string Header { get; set; }
public Meta Meta { get; set; }
}
}
and...
using Our.Umbraco.Ditto;
namespace Undiscovered.Site.Logic.Model.Content.Composite
{
public class Meta
{
[UmbracoProperty("metaTitle", null, false, "Default Value, wahoo!")]
public string Title { get; set; }
public string Description { get; set; }
public string SocialTitle { get; set; }
public string SocialDescription { get; set; }
public string SocialImage { get; set; }
}
}
Ditto is working directly with the IPublishedContent object, which doesn't care about the doctype compositions (in the nicest possible way) ... it has a bunch of properties - which is what Ditto will pull values from.
In your case, if you are mapping your current content node to the Home type, it will loop over the properties, find Meta and look for a property on the node called "Meta" - which it doesn't look like it has ... so leaves it as null.
Because you'll want to re-apply your content node to the nested class... then you can add a processor attribute called CurrentContentAs to the Meta property...
Document Type Composites
Hey!
Wondering how Ditto handles composite Document Types?
For the example below, would you create 2 pocos?
Article
Meta
Something like:
and...
Which does not work ;-)
Hi Lau,
Ditto is working directly with the
IPublishedContent
object, which doesn't care about the doctype compositions (in the nicest possible way) ... it has a bunch of properties - which is what Ditto will pull values from.In your case, if you are mapping your current content node to the
Home
type, it will loop over the properties, findMeta
and look for a property on the node called "Meta" - which it doesn't look like it has ... so leaves it asnull
.Because you'll want to re-apply your content node to the nested class... then you can add a processor attribute called
CurrentContentAs
to theMeta
property...Then that should work as you'd expect it to.
Hope this helps?
Cheers,
- Lee
Cheers Lee! I knew I had read about it somewhere in the docs ;-) Thanks again! Laurence
is working on a reply...