Sample Contentstack Complete Entry Model Class

The ResourceEntry class below provides an example of a complete Entry Model Class for the Contentstack SaaS headless CMS. This Entry Model Class represents a generic type of content resource (also the name of its Content Type) that can manage several different types of content in a Modular Blocks Field.

There really is not much to this class because it mostly exposes properties derived from base classes ( and coded in other classes ( The implementation does not highlight the significant functionality provided by those base classes and hence this class, nor a significant amount of infrastructure for REST that makes all of this possible.

This Entry Model Class inherits from WebpageEntry, which models the URL field in Webpage Content Types that can have URLs as well as the PageDataField Group that can contain custom metadata relevant to any page.

In turn, WebpageEntry inherits from ContentBlockEntry, which exposes properties common to all types of Entries, such as creation date and version, as well as custom properties, such as a handle on the repository used to populate the Entry Model.

This class has one more property (Links) for a different Modular Blocks Field that is not worth describing, so really it only defines one property.

You can see that I use a custom attribute to associate the Entry Model Class with a Content Type so that the repository can determine a default Entry Model Class for a Content Type.

I just noticed that ContentBlockEntry has an EditLink property. I want developers to be able to use CMS login status to enable or disable UI features that support editing content while browsing the site rather than navigating the CMS. Clicking something in the page could open an Entry in a new tab for editing. I want to expose this feature for Entries referenced by the Entry that represents data for the current page, where those referenced Entries may not ave URLs that appear on the site.

For now, I just use this add a link around the main heading on the page, which is visible even if the visitor has not authenticated as a CMS user.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: