Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alejandro Ocampo 67 posts 330 karma points c-trib
    Jun 07, 2016 @ 12:21
    Alejandro Ocampo
    0

    Ditto is not mapping OK

    Hi there,

    so I got these models:

    [PublishedContentModel("Stations")]
    [TypeConverter(typeof(DittoPickerConverter))]
    public class Stations : PublishedContentModel
    {
        public Stations(IPublishedContent content)
            : base(content)
        {
    
        }
    
        [UmbracoProperty("travelTipsDefaultSet")]
        public IEnumerable<TravelTip> TravelTips { get; set; }
    
        [UmbracoProperty("partnershipDefaultSet")]
        public IEnumerable<PromoBox> PartnerShips { get; set; }
    }
    
    
    [TypeConverter(typeof(DittoPickerConverter))]
    public class TravelTip
    {
        public string Name { get; set; }
    
        public IPublishedContent Image { get; set; }
    
        public MultiUrls Link { get; set; }
    
        public string Description { get; set; }
    }
    
    
    [TypeConverter(typeof(DittoPickerConverter))]
    public class PromoBox
    {
        public IPublishedContent PromoImage { get; set; }
    
        public MultiUrls PromoLink { get; set; }
    }
    

    For some reason that I can't understand TravelTips is mapping OK but PartnerShips is not.

        var parentNode = Model.Parent.As<Stations>();
        var partnershipDefaultSet = parentNode.PartnerShips;
        var z = parentNode.TravelTips;
    

    Ideas ?

    Thanks,

    Ale

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2016 @ 12:35
    Lee Kelleher
    0

    Hi Ale,

    Is the Umbraco property alias that it's being mapped with definitely called "partnershipDefaultSet"?

    I recall Ismail having an issue where the nodes picked by an MNTP had become unpublished?

    https://our.umbraco.org/forum/developers/api-questions/75382-getpropertyvalue-returns-null#comment-241260

    Cheers,
    - Lee

  • Alejandro Ocampo 67 posts 330 karma points c-trib
    Jun 07, 2016 @ 12:44
    Alejandro Ocampo
    0

    Hi Lee,

    That's not the case and 100% the prop alias is "partnershipDefaultSet"

    enter image description here

    Any other suggestion ?

    Cheers,

    Ale

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2016 @ 12:46
    Lee Kelleher
    0

    ...and the selected nodes of the MNTP are published?

    (sorry if that sounds abrupt, just that I spend a fair amount of time with Ismail on this previously)

  • Alejandro Ocampo 67 posts 330 karma points c-trib
    Jun 07, 2016 @ 12:53
    Alejandro Ocampo
    0

    The same mapping public IEnumerable<PromoBox> PartnerShips is working with other models using the same MTNP nodes.

    (No worries, :) )

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2016 @ 13:01
    Lee Kelleher
    0

    From the code / configuration perspective, it all looks okay to me.

    The only reasons it would be mapping PartnerShips is if the were no nodes to map it to, or that internally DittoPickerConverter couldn't work with the value from MNTP (and returned a null).

    If you were to call...

    Model.Parent.GetPropertyValue("partnershipDefaultSet");
    

    ...what would you get back? Is it a CSV string of node IDs, or a list of IPublishedContent objects, or something else?

    Thanks,
    - Lee

  • Alejandro Ocampo 67 posts 330 karma points c-trib
    Jun 07, 2016 @ 13:13
    Alejandro Ocampo
    0
    var parentNode = Model.Parent;
    var partnershipDefaultSet = parentNode.GetPropertyValue<IEnumerable<IPublishedContent>>(DocTypes.Stations.Properties.PartnershipDefaultSet._Name);
    

    enter image description here

    var y = parentNode.GetPropertyValue("partnershipDefaultSet");
    

    enter image description here

    To get this working I can remove the prop from the model and then just handle it with IpublishedContent but TBH I got no idea why ditto is getting crazy with it and I'm curious now. If the code looks OK, what else could that be ?

    Cheers,

    Ale

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2016 @ 13:40
    Lee Kelleher
    0

    Thanks for the info. Hmmm, Ditto should be totally fine with taking a list of IPublishedContent, not sure why it wouldn't be mapping.

    Just for clarification, when you say that PartnerShips isn't mapping... what is the value of parentNode.PartnerShips here?

    var parentNode = Model.Parent.As<Stations>();
    var partnershipDefaultSet = parentNode.PartnerShips;
    

    ... is it actually null or an empty list of PromoBox?


    I'm trying to figure out from the Ditto code where it might not be working...

    https://github.com/leekelleher/umbraco-ditto/blob/0.8.4/src/Our.Umbraco.Ditto/ComponentModel/TypeConverters/DittoPickerConverter.cs#L86

    ...

    One last question, has this worked before? Just curious if it's a new property or something that has recently broken.

    Thanks,
    - Lee

  • Alejandro Ocampo 67 posts 330 karma points c-trib
    Jun 07, 2016 @ 13:57
    Alejandro Ocampo
    0

    The same prop is mapping OK with other models, check the values:

    enter image description here

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2016 @ 14:59
    Lee Kelleher
    100

    OK, we can see that it's definitely creating a list of PromoBox objects, but each one of them is null. Which I suspect that DittoPickerConverter isn't playing nicely with...

    Try removing the TypeConverter attribute from the PromoBox class and adding it to the PartnerShips property.

    [TypeConverter(typeof(DittoPickerConverter))]
    [UmbracoProperty("partnershipDefaultSet")]
    public IEnumerable<PromoBox> PartnerShips { get; set; }
    

    See if that helps?

    Cheers,
    - Lee

Please Sign in or register to post replies

Write your reply to:

Draft