Table of Contents

Content-Type (Schema/Object-Type)

This explains Content-Types. For an overview check out Understanding Data....

What is a Content-Type?

Every Entity (thing, record or object) in 2sxc has a definition of fields it can have. So a Book may have fields like Name, Author, Title etc. The Content-Type will define what fields exist, what is required and what order the fields will appear in when editing the item.

This definition of the Type is called a Content-Type and it contains specs as to the exact fields are used and what their field-types are.

Other systems may call this Schema, Object-Type, Object-Structure or Table Definition

Tip

Before you start: Remember that you usually don't need this if you are creating Razor templates or WebApi - for that, you want to read Dynamic Entity Objects.

Where are Content-Types

What's Defined in a Content-Type?

Content-Types are a configuration which contains:

  1. The list of fields the Content-Type has with the technical name, like ProfilePhoto
  2. Edit-UI information for the edit form
    1. The order of the fields should be shown in when editing
    2. A user friendly name like Profile Photo and editing help texts like This should only contain head & shoulders
    3. The Input-Type which the UI should show, like Hyperlink (which means that it's a link or file)
    4. Input-Type configuration, for example AllowUpload etc.
  3. Optionally some of the Edit-UI information in more languages like Profilbild in German
  4. Optionally permission information like May be used in Mobile Apps for read-only

Nice to Know: Edit Content-Types

  1. Content-Types are configured in the App-Management UIs
  2. You can create new Content-Types at any time
  3. You can rename a Content-Type at any time
    1. If you change the display-name (like Blog Post to Blog Entry) then your code doesn't need changes.
    2. If you change the technical name (BlogPost to BlogEntry) then your code needs to be updated
  4. You can delete Content-Types at any time
    When you delete a Content-Type, all Entities/Items of that type are deleted
  5. Content-Types have additional descriptions and help-texts which are shown in the Edit-UI
  6. Content-Types can also have an icon, but that's only used in Content Mode

Nice to Know: Edit Fields of a Content-Type

  1. You can always create new fields on a Content-Type
    When you add new fields, then existing data will have that field, but no values on these fields
  2. You can always delete existing fields on a Content-Type
    When you remove fields, existing data will lose those values
  3. You can always rename fields of a Content-Type
    1. When you change the display name of a field (like Persons Photo to Profile Picture) the technical field name doesn't change, so your code doesn't need modification.
    2. If you change the technical field name (like ProfilePic to ProfilePhoto) the code must be updated

Nice to Know: Export / Import Content-Type Definition

  1. You can export a Content-Type into a JSON format
  2. You can import the Content-Type into another App using upload or drag-n-drop
Important

Exporting the Content Type Definition exports the schema / fields of that type.

Exporting all the Items of a Content-Type is a table-export of all the data.


Content-Type - More Information

Identity of a Content Type: Name and StaticName

Each content-type has a Name, which is nice for a human to read, use and program with. There is a second identifier called StaticName which is usually a GUID, but in rare cases it's a string like App-Settings. This identifier is used internally - for example when a View references a Content-Type.

Storage

Most Content-Types in your App are stored in the SQL database. System and global Content-Types are stored in the file system. These are called File-Stored Content-Types

Field Types

Each field will be of a simple type like text/string, number, boolean (yes/no) or other. You can find the list of types here.

Relationships

Fields can also be of type Entity in which case they point to other items. This would then establish a Relationship

Input Forms and Fields (like WYSIWYG)

The input mask is automatically generated from the Content-Type. Based on the specifications, it will generate the correct Input-Field like a simple text field, a multiline text field, a WYSIWYG or even a file-uploader.

Scopes

Content-Types have a Scope. Read about it Content-Type Scopes

APIs

History

  1. Introduced in 2sxc 1.0