More about inheriting content items

In this section we'll explore how we can inherit content items and some of the attributes that gets the N2 engine working.

Multiple types of items

  • When we start creating more types of items we can give each type a name to distinguish it in edit mode.
  • We can also override the IconUrl property and have it return the url to an icon.


  • The examples contains two classes deriving from N2.ContentItem.
    • MyItemBase: an abstract class defining an editable title and name
    • TextPage: a class containing an editable property, Text. Since this class isn't abstract it is available in edit mode when we create new pages.

Our custom base class...

...is a N2.ContentItem

Define editable properties

  • This class has some attributes, the Item attribute and the HasEditable attribute (the attribute name has recently changed to WithEditable).
  • The Item attribute defines information about the item
  • The WithEditable attribute defines editable properties/details in the class or any base class. In this case we are defining an editable Title and Name.
  • Actually there is no requirement of a property with the name defined on the WithEditable attribute. If no property with the same name exists the value is stored in the detail collection. More about details later.

Dissecting the WithEditable attribute; display name

  • It has a display name which is the label the editors see when they are editing

Content item property name

  • It has a property name which is the property (or detail) name on the content object that will receive the value that is beeing edited.

Editor control

  • It has a type of control used for the editing (in this case it's a textbox)
  • It has a property on the editor control which will contain the value when we save (textbox.Text)

Now what?

Why not learn more about how contnet items are defined, or look at the data binding options available for the presentation templates, or perhaps, check out the API for managing content programmatically.

Have you already built a site and want to content-enable it? Learn about configuring it to use N2.

By the way have you checked out the templates project? There is a demo available here. The code is available in the source code release.