Have you ever wondered how to write end-to-end tests for your Orchard Core application? Check out our current post to read about Cypress, which is a next generation front end testing tool built for the modern web. But first, let's start with the other exciting improvements!
This time we will do a little deep dive and check out some important changes in the code base of Orchard Core. But don't be scared, we promise you will like these changes, especially the demo about the new User Picker Field!
You have implemented your
MyAwesomePartbut you cannot attach it to your content type using the dashboard because it's not showing in the Content Parts list (Content -> Content Definition -> Content Parts)?
The most possible reason for this that you haven't registered your implementation in the service container. To register your class in the service container head to the Startup.cs file of your module and in the
ConfigureServicesmethod add the following line:
But if you are using the RC1 version of Orchard Core or newer you can use the
AddContentPartextension method, where you just only need to provide your content part:
AddContentField(that you can use to register your fields) can be found in the OrchardCore.ContentManagement namespace.
Another recommendation is to use the Part suffix when naming your class or cs file that contains your custom part. Don't forget to put it in a Models folder to follow the recommendation of the MVC (model-view-controller) software design pattern.
For more information about registering your Part check out the Startup.cs file of our Orchard Core Training Demo module, where we registered the
PersonPartin the service container. We also mentioned the new way of registering ContentParts and ContentFields in this post of our This week in Orchard series.