Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Custom IContent Property on Page/Block/IContent


Is it possible to use a custom IContent type as a property on a page/block/content?

For example, lets say I have the following class:

[ContentType(DisplayName = "Address", GUID = "89d1de01-1963-478f-bc27-1cdff8470c69", Description = "")]
    public class Address : IContent, ContentBase
        //ContentBase and custom properties omitted for brevity

And I want to use it as a property (like a local block, but not a block) on a page/block/content:

    [ContentType(DisplayName = "Location", GUID = "e6c37d80-1de3-434e-a1d1-7a050e15a97f", Description = "")]
    public class Location : ContentBase
        //other properties omitted for brevity
        public virtual Address Address { get; set; }

This errors complaining about the property not being able to be mapped to a PropertyDefinitionType.

I know that I can implement complex custom properties (storing the values as JSON) using PropertyDefinitionTypePlugIn, but if possible, I'd like to leverage the "local block" functionality to render those fields automatically.  Is there a way to treat custom IContent properties the same as a "local block?"

Edited, Feb 21, 2018 23:42

No it is not possible, block is a special kind of content explicitly designed to be used both as property on other content but also as stand alone instances (shared blocks).

If you look at the definition of BlockData you can see that it does not implement IContent, instead is the interface "injected" at runtime for shared block instances.

Feb 22, 2018 8:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.