Search code examples
orchardcmsorchardcms-1.8orchard-modules

Orchard CMS - ContentPart Namespacing


Does Orchard support multiple content parts with the same name but in different modules?

For example:

namespace MyNamespace
{
    public class PersonPart: ContentPart<PersonPartRecord>
    ...
}

namespace OtherNamespace
{
    public class PersonPart: ContentPart<PersonPartRecord>
    ...
}

The tables generated for content parts seem to fully qualify the part via a namespace prefix such as:

Current_MyNamespace_PersonPartRecord

When the part is mapped to a content type, I typically would do something like:

ContentDefinitionManager.AlterTypeDefinition("Person", builder => builder
    .Creatable()
    .WithPart("CommonPart")
    .WithPart("PersonPart"));

which doesn't provide any namespacing for resolving the part.

Is there a mechanism that I am missing for allowing multiple content parts with the same name in different modules, or do I always need to make sure there are no naming collisions with the part's short name?


Solution

  • Content parts with the same name cannot appear multiple times in a single content type by design.

    I don't quite get the benefits of adding namespacing functionality. The added value seems really small, but potential issues that would arise are substantial (problematic refactoring, troublesome overriding of existing parts etc.).

    Just make sure to name them differently and you're good.