Working with Content Fields

Topics: Customizing Orchard, Writing modules
Aug 18, 2011 at 10:38 AM

I am starting to work with Orchard. I downloaded the Image Field Module, which adds a Content Field that can be added to Content Types.

I added an Image Field to a selfbuild Content Type (MarinaPage) via the Dashboard. But our main goal is to work with the source code or commandline, and less with the Dashboard. Two questions arose:

Where in the source code do I find the Image Field? I have looked, but to no avail.

Where in the source code is the setting saved, that the Content Type MarinaPage has an Image Field? 

There are also a few question I have regarding a similar issue: The Content Type MarinaPage has also a Conent Part MarinaPart. Essentially the Image we store in the Image Field "belongs" to the MarinaPart (no other MarinaPart can have the same picture). Two questions to this:

Are the Content Part MarinaPart and the Image Field somehow connected in the SQL database?

Can I programmatically access the other if I have one of the two?

And generally speaking: Am I doing the right thing here? Can you point me to clarifying threads or docs?

Aug 18, 2011 at 6:00 PM

1- If you installed the Image Field module, then it is in websiteroot/Orchard.Web/Modules/Contrib.ImageField. And this module is maintained at

2- I think what you need is to know how the ContentDefinitionManager is working. Here is an example I took from an existing module (Orchard Gallery) which adds a new Field definition while the module is installed:

        public int UpdateFrom5() {
            ContentDefinitionManager.AlterPartDefinition("ProfilePart", builder => builder.WithField("OptOut", cfg => cfg.OfType("EmailOptOutField")));
            return 6;

Every thing which is done in the UI can be done as a module, or during any event in this module. And everything which is persistent, is in the database, yes.

Aug 18, 2011 at 7:24 PM

Sounds good!

So what if I had two different modules that define a ContentField of the same name? How does Orchard find the right one? Why don't we use strong references to the respective modules with their types instead of strings?

Aug 18, 2011 at 7:28 PM

Two field types can't have the same name. I assume the module loading order will prevail.