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 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.
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");
}
}
}
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
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
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.
Hi Jeavon,
Looking forward to seeing that. I'm always rolling out my own convertors.
Dave
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:
Yes, It's working!
Still learning a lot :-)
Great! Value Converters are documented here if you want to understand more about what they are doing.
is working on a reply...