Copied to clipboard

Flag this post as spam?

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


  • Robbie van den Hoven 36 posts 181 karma points
    Jun 25, 2015 @ 06:44
    Robbie van den Hoven
    0

    How to use Core Property Value Converter on a custom datatype?

    Can someone tell me how you can use the Umbraco Core Property Value Converters on a custom datatype that is a copy of an ‘original’ datatype.

    I'm using the 'original' Multiple Media Picker with the benefit of the Umbraco Core Property Value Converters. I would like to change these Media Pickers with the Extended Media Picker datatype, but then the Value Converter doesn't work anymore.

    How can I hook the Value Converter of Umbraco.MultipleMediaPicker to work on CTH.ExtendedMediaPicker?

    I asked the question to the package creator, but it's more a general question I guess

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Jun 25, 2015 @ 07:07
    Dave Woestenborghs
    1

    I don't think it's possible. Property Value Convertors are tied to a specific property editor. You can always roll out your own.

    The source of the Multiple Media picker convertor can be found here : https://github.com/Jeavon/Umbraco-Core-Property-Value-Converters/blob/v2-release/Our.Umbraco.PropertyConverters/MultipleMediaPickerPropertyConverter.cs

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jun 25, 2015 @ 07:11
    Jeavon Leopold
    0

    I think you should be able to call the existing methods from the multi media picker converter in your own. I will post the code later (if no one else has already by then) when I'm in the office.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Jun 25, 2015 @ 07:13
    Dave Woestenborghs
    0

    Hi Jeavon,

    Looking forward to seeing that. I'm always rolling out my own convertors.

    Dave

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jun 25, 2015 @ 10:34
    Jeavon Leopold
    103

    Ok, so as this editor is exactly the same as the MultiMedia picker, we can create a very simple value converter that inherits and override only the IsConverter method like this:

    namespace MyProject.PropertyConverters
    {
        using Our.Umbraco.PropertyConverters;
    
        using Umbraco.Core.Models.PublishedContent;
    
        public class ExtendedMediaPickerPropertyConverter : MultipleMediaPickerPropertyConverter
        {
            public override bool IsConverter(PublishedPropertyType propertyType)
            {
                return propertyType.PropertyEditorAlias.Equals("CTH.ExtendedMediaPicker");
            }
        }
    }
    
  • Robbie van den Hoven 36 posts 181 karma points
    Jun 25, 2015 @ 10:45
    Robbie van den Hoven
    0

    Yes, It's working!

    Still learning a lot :-)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jun 25, 2015 @ 11:28
    Jeavon Leopold
    0

    Great! Value Converters are documented here if you want to understand more about what they are doing.

Please Sign in or register to post replies

Write your reply to:

Draft