This project is read-only.

[OrchardFeature("...")] attribute Hide Content Type

Topics: General, Troubleshooting
Jan 30, 2014 at 8:14 AM
I'm using the OrchardFeature attribute, I haven't enabled the module yet I can see the content type in the "New" list

I've added the attribute to all classes, Here is a list of my files:
public class ResultPartRecord : ContentPartRecord

public class ResultPart : ContentPart<ResultPartRecord>

public class ResultPartDriver : ContentPartDriver<ResultPart>

public class ResultPartHandler : ContentHandler
I haven't added the attribute to my Migrations that creates the content type:
ContentDefinitionManager.AlterTypeDefinition("Result", cfg => cfg
                                                                              .WithPart("CommonPart", builder => builder.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
How can I hide / show the content type based on if the Module is enabled?
Jan 30, 2014 at 8:33 AM
I believe the conventional way is to have separate migration classes for each feature, and decorating each migration class with OrchardFeature attribute.

Jan 30, 2014 at 8:36 AM
Thanks, makes sense, i should have thought of that.
Jan 30, 2014 at 8:50 AM
Looking further, this works fine if you never enable the module.

There is a bug... if you disable the module you would expect the content types to hide.
Jan 30, 2014 at 11:46 AM
Not really. Content types are definitions saved in the DB. When your create a content type in a migrations or somehow else it gets persisted in the DB. Later you don't need the migrations to be able to construct a content item of that type since its definition comes from the DB - thus you could also remove the migrations, the content type still remains.

If you want to remove the content type when the module is disabled you could do this from an IFeatureEventHandler implementation.