kontent-ai / delivery-sdk-net

Kontent.ai Delivery .NET SDK
https://www.nuget.org/packages/Kontent.Ai.Delivery
MIT License
32 stars 42 forks source link

Models using IRichTextContent don't resolve inline modular content #107

Closed ChristopherJennings closed 6 years ago

ChristopherJennings commented 6 years ago

I've discovered that if my models use IRichTextContent for the type of a field, the default inline content resolver will not process it.

This appears to be because the CodeFirstModelProvider only adds properties of type string to the list of rich text properties to be processed, but I'm not sure if this is the full reason or not. See: https://github.com/Kentico/delivery-sdk-net/blob/4d1701d04830f72d5f5571de31d59682a9d4e900/KenticoCloud.Delivery/CodeFirst/CodeFirstModelProvider.cs#L137

petrsvihlik commented 6 years ago

Hey @ChristopherJennings , this is intended.

The inline resolver is used only for the string-based resolution: https://github.com/Kentico/delivery-sdk-net/wiki/String-based-rendering-of-modular-content-items-in-Rich-text

The resolution of IRichTextContent and its IRichTextBlocks should happen later. For instance, within Views and Display templates in MVC as described in https://github.com/Kentico/delivery-sdk-net/wiki/Structured-Rich-text-rendering. The SDK just fills the IRichTextContent property with structured data.

If you want to use IRichTextContent outside MVC then you have to resolve the property yourself. The other option is to use just plain string properties in the model (you can instruct the model generator to do so).

Feel free to reopen the issue if you have more questions.