This project is read-only.

Disable Content Types in the Templates Site

Topics: Developer Forum
Sep 4, 2008 at 9:58 PM

I'm playing around with the templates site and would like to restrict users from creating certain types of content items. For example, only plain content items and a news container under the start page.

Sep 4, 2008 at 10:48 PM
This would involve some coding. Either remove them from the project or disabling them programmatically.
Sep 5, 2008 at 8:20 PM
To remove them from the project would involve recompiling the Templates Project DLL without the unwanted content types, right?

How could they be disabled programmatically?

Thanks for the help!
Sep 5, 2008 at 11:43 PM
Yes, remove would mean recompiling.

One option is to use an attribute called replace definitions. It will cause the types to be disabled.

[assembly: ReplaceDefinitions(typeof(N2.Templates.Items.FormPage), typeof(N2.Templates.Items.ImageGallery, ...))]

Another option is iterating the definitions collection and disabling items programmatically:

foreach(ItemDefinition definition in N2.Context.Current.Definitions.GetDefinitions())
    definition.Enabled = false