What is the IContent Interface?

In This limitation meant that a lot of developers would hack the system and create a NewsItemPageType for example, that would be used to populate a news feed.  This worked in most situations, but the approach definitely had its limitations.

With the ever growing needs of content editors to be able to manipulate different things within the editor, from Episerver 7 the notion of supporting multiple content types was introduced.  The notion of blocks is a great example, instead of having to hack a special page type to display a carousel slide for example, a carousel slide block could be created instead.  This makes the page tree a lot more manageable as we can now create custom content types to cater for any situation.

In order to implement this functionality, Episerver made a fundamental change by introducing a content interface. The content interface is the basic building block that will allow a page, block, blog comment or whatever type you want to create, work with Episerver. The content interface is called IContent.

IContent

IContent can be found in the Episerver.Core namespace and it defines six members that must be implemented in order for the content type to work in Episerver.

Name In order for a bit of content to exist in Episerver it must have a name. The name is a string and will be the thing Episerver displays in edit mode.

ContentLink This is the Episerver way of uniquely identifying the content, which uses a custom Episerver object called a ContentReference.  More information about this unique code can be found in, Why Does Episerver Need A Content Reference?

ParentLink This should point to the content item’s parent item in the page tree.  In Episerver the StartPage is a special content type that defines the websites main page or home page.  It’s the page your website visitors will see when they first reach your website.  The navigation tree build up the pages defined under the StartPage.  So in order for a piece of content to exist, Episerver needs to know where it will live in relation to the Start page.

IsDeleted The IsDelete member tells Episerver if the page has been ‘soft’ deleted.  Soft deleted means that the page may still exist in the database, but a content editor may have moved it into the trash bin.  If items are moved into the Trash then they will not be displayed on the website.

ContentTypeID The Content Type Id describes the content type within Episerver.  For a very basic example, a page may have an ID of 1, a block might have an ID of 2 and a blog post might have an ID of 3.  When we try and get content out of the Episerver API and we want to get a page for example, ensuring that the content has a content type defined makes tasks like searching a lot quicker.

ContentGuidThe idea of needing a content Guid can be confusing when we already have a content link defined that uniquely identifies the content.  The ContentLink tells Episerver how to find the content.  The ContentGuid is the thing that uniquely identifies the item within the EPiServer system.

One reason why this property is required is to support tasks like content migration. If you are trying to do an EpiSever content migration (import/export) from an old website into a new database, you may very well have another content item on the new site with the same ContentReference. The ContentGuid ensures these items can be differentiated.

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

1 reply

Trackbacks & Pingbacks

  1. […] This interface definition is called the iContent interface. More information about the iContent interface can be found in this EpiServer CMS tutorial, What is the IContent Interface? […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *