You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
This feature request aims to provide easier custom implementations on project side without modifying core. Application can be in custom importers, typed fetching of elements on project side etc. Right now I have problems with creating custom implementations that work with elements.
Example on Elements property:
I have a blog post type defined in CMS (so it is a dynamic content type). It has some fields that I want to fetch, but I do not want to register it in code. So I have concrete class, that inherits ContentPart and exposes some fields (dont want to use deserialize/reflection/..).
But there is a problem - when I use contentItem.Get("BlogPost") in controller, it works okay. But when I call it at indexprovider level, it throws exception.
Exception is thrown because at IndexProvider, Elements array is already filled up. And it contains "BlogPost" entry with a different type (ContentPart) that can not be casted to my type (BlogProps). So what I can do now is to clear Elements array and it will work again. But I cannot do that from project level, so my only way to clear it, is to call self referencing merge - "contentItem.Merge(contentItem, replacesettings..);" because it contains this Elements.Clear().
Example on data property:
I have created a custom importer that transforms CSV data from old solutions like Joomla and I am using contentManager to handle data operations. But that means I need to transform data to ContentItems.
Currently, there is no option to customize data from project. So I need to do this:
var json = JsonConvert.SerializeObject(importModel);
var model = JsonConvert.DeserializeObject(json);
This approach uses predefined JsonConvertor from OC that will transform data to form I need, but it is not very elegant.
Describe the solution you'd like
In my opinion, properties on ContentItem should be public, so it is possible to play with them as needed. It is well designed for usecase that currently OrchardCore needs, but for customization, it becomes very challenging when I do not want to customize core packages.
Basically it is about making ContentElement.Data and ContentElement.Elements public
Describe alternatives you've considered
Dont know any, feel free to suggest something else. I know many other people did their importers, so maybe there is other way.
For elements, solution might be also some parameter "UseCache" that allows to ignore fetching from elements.
Is your feature request related to a problem? Please describe.
This feature request aims to provide easier custom implementations on project side without modifying core. Application can be in custom importers, typed fetching of elements on project side etc. Right now I have problems with creating custom implementations that work with elements.
Example on Elements property:
I have a blog post type defined in CMS (so it is a dynamic content type). It has some fields that I want to fetch, but I do not want to register it in code. So I have concrete class, that inherits ContentPart and exposes some fields (dont want to use deserialize/reflection/..).
But there is a problem - when I use contentItem.Get("BlogPost") in controller, it works okay. But when I call it at indexprovider level, it throws exception.
Exception is thrown because at IndexProvider, Elements array is already filled up. And it contains "BlogPost" entry with a different type (ContentPart) that can not be casted to my type (BlogProps). So what I can do now is to clear Elements array and it will work again. But I cannot do that from project level, so my only way to clear it, is to call self referencing merge - "contentItem.Merge(contentItem, replacesettings..);" because it contains this Elements.Clear().
Example on data property:
I have created a custom importer that transforms CSV data from old solutions like Joomla and I am using contentManager to handle data operations. But that means I need to transform data to ContentItems.
Currently, there is no option to customize data from project. So I need to do this:
var json = JsonConvert.SerializeObject(importModel);
var model = JsonConvert.DeserializeObject(json);
This approach uses predefined JsonConvertor from OC that will transform data to form I need, but it is not very elegant.
Describe the solution you'd like
In my opinion, properties on ContentItem should be public, so it is possible to play with them as needed. It is well designed for usecase that currently OrchardCore needs, but for customization, it becomes very challenging when I do not want to customize core packages.
Basically it is about making ContentElement.Data and ContentElement.Elements public
Describe alternatives you've considered
Dont know any, feel free to suggest something else. I know many other people did their importers, so maybe there is other way.
For elements, solution might be also some parameter "UseCache" that allows to ignore fetching from elements.
Related also to #15530 (reply in thread)
The text was updated successfully, but these errors were encountered: