-
Hello, I'm a newbie of Orchard Core and I'm currently diving deeper into Orchard Core to understand best practices. I've been following the "Dojo Course 3" video series, and videos 28 and 29 clearly explain how to create custom "Content Parts", which is useful for creating reusable components, such as a carousel module for example. I also read the documentation about custom Content Fields. For example, as exercise I'm trying to develop a bookshop manager and I need to create a custom "Content Part" for a Is this scenario appropriate for a custom "Content Field"? In the past I used Umbraco, where it was very helpful to specify a validation regex for every field of an object I created. My question is: how do you determine when you need a custom "Content Field"? In the "Content Parts", you can define your custom model with your custom types and complexity. So, when is it recommended to break it down into custom smaller pieces, and create custom Content Fields? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
I am not much of a contributor to OrchardCore, so take this with a grain of salt (but have been using Orchard and OrchardCore for many years). I will explain how I think of things though and maybe it will help. First, for your regex example, I would just use a custom editor for the existing text field. So then you would have an option like this on text fields Content Fields are in a way similar to properties on a class, and then parts are the class (only true for parts that are just collections of fields). As a matter of fact you can create a content part class in code that does just that. Basically I think of content fields as a way to display and edit a single value (like a form field, but displays its value on the frontend). The field may be storing more than just the value in the database, but it is still typically to support just displaying and editing a single value for the user. Content Parts can be as simple as a collection of content fields, or can provide content items of the content type the part is on with additional functionality. For instance, we have a custom part called PrintPart. It provides the functionality for our content types to have a print button on them and then generate a printable PDF from a liquid template. In that case the part isn't even storing any values, and is just providing functionality. Maybe some examples for custom fields and parts we have created would help? Some of our parts: Does this help at all? |
Beta Was this translation helpful? Give feedback.
I am not much of a contributor to OrchardCore, so take this with a grain of salt (but have been using Orchard and OrchardCore for many years). I will explain how I think of things though and maybe it will help.
First, for your regex example, I would just use a custom editor for the existing text field. So then you would have an option like this on text fields
Content Fields are in a way similar to properties on a class, and then parts are the class (only true for parts that are just collections of fields). As a matter of fact you can create a content part class in code that does just that.
Basically I think of content fields as a way to display and edit a single value (like a form field…