Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
My guess would be that you're getting a type casting error under the hood. Check your logs and browser console for errors. You would probably need to do quite a bit more work in your `PropertyDefinitionTypePlugIn` to handle conversion by overriding the `Value` prop (and potentially other properties/methods).
I am curious however why you would want a new custom ContentArea property, I can't think of many use cases to do so...
Yeah, I am with Daniel on this one, not many use cases for a custom content area property, however looking at the name of the property you are trying to create, I think you are trying to create a different user experience and make the content area expandable.
If this is the case you don't need a new property you just need to override the editing experience.
The guys at Ted & Gustaf have an example that might be useful if you wish to just override the editing experience.
https://tedgustaf.com/blog/2016/create-a-custom-editor-for-a-content-area-in-episerver/
I have a custom property converter provider that calls a custom content area property converter. what I am trying to do is check if the property value type is of a certain type then call my expand method when it is.
public class CustomPropertyConverterProvider : IPropertyConverterProvider
{
public int SortOrder => 200;
public IPropertyConverter Resolve(PropertyData propertyData)
{
if (propertyData is PropertyContentArea)
{
return new CustomContentAreaPropertyConverter();
}
return null;
}
}
[ServiceConfiguration(typeof(IPropertyConverter), Lifecycle = ServiceInstanceScope.Singleton)]
public class CustomContentAreaPropertyConverter : IPropertyConverter
{
public IPropertyModel Convert(PropertyData propertyData, ConverterContext converterContext)
{
if (propertyData is not PropertyContentArea propertyContentArea)
{
throw new InvalidOperationException();
}
var model = new ExpandedContentAreaPropertyModel(propertyContentArea, converterContext, ServiceLocator.Current.GetInstance<IContentExpander>());
if (propertyData.PropertyValueType.Name == nameof(CustomExpandableContentArea))
{
model.Expand(converterContext.Language);
}
return model;
}
}
Hi Taher,
I just thought I would get back to you on this.
From what I can see you are trying to expand the content area when using the Content Delivery API, is this correct?
If so then you don't need to create a custom content area property, you just need to change how the Content Delivery API converters the content area to json when serializing, you can see this upon https://docs.developers.optimizely.com/content-management-system/v1.5.0-content-delivery-api/docs/customizing-conversion-from-icontent-to-contentapimodel#example-expand-multiple-levels-of-nested-contentarea-property.
A colleague of mine also has a good blog post of this type of customization https://world.optimizely.com/blogs/Minesh-Shah/Dates/2022/2/property-lists-serialization-and-content-delivery-api/, this is for a property list however all the code should be there to follow along and do the same for content areas.
Hi all,
i am working on creating a custom content area which inherits from ContentArea
I also implemented my custom content area property to go with it
I also implemented my EditDescriptor
and in my ContentType I implemented it as this
When I add any type of content inside of my custom content area it throws this error in a dialog:
Could not save property. The page may have been changed by another user. Please reload the page.
I have tried everything, any help is appreciated.