# Content Types

Content types, define reusable schemas for documents. You can for example create a content type called `Page` or `Product` to re-use a certain set of fields.

## Adding Content Types

To create a content type:

1. Navigate to the page 'Content Types' by clicking the double-square icon in the menu bar on the left.
2. On this page you'll find a 'Create Type'-Button at the top right corner.
3. Enter `Name` and `Api-Id` and click 'Save'*.*
4. Now you can start editing your new content type.

## Editing Content Types

On the page 'Content Types' you'll see an overview of existing content types. You can simply click one of them to enter the edit mode and to add and remove fields or to change their configuration.

{% hint style="warning" %}
If you remove a field with existing content, the content of these fields will be **deleted**.
{% endhint %}

### Field Types

| **Name**    | **Options**                  | **Validation**                              | **Translatable** | **API Output**                                        |
| ----------- | ---------------------------- | ------------------------------------------- | ---------------- | ----------------------------------------------------- |
| Text        | Single Line, Multi Line      | Required, E-Mail, Min. length, Max. length  | ✔️               | `string`                                              |
| Richtext    | –                            | Required, Min. length, Max. length          | ✔️               | `[plain, html]`                                       |
| Markdown    | –                            | Required                                    | ✔️               | `string`                                              |
| Number      | Integer, Decimal             | Required, Min. value, Max. value            | ✔️               | `number`                                              |
| Select      | Select, Radio, Checkboxes    | Required                                    | ✔️               | `string\|array`                                       |
| Assets      | –                            | Required, Min. count, Max. count, Filetypes | ✔️               | `array`                                               |
| Date & Time | Date, Date & Time, Time only | Required                                    | ✖️               | <p><code>string</code> <br><em>ISO 8601, UTC</em></p> |
| Relation    | One to one, One to many      | Required, Min. count, Max. count            | ✖️               | `object\|array`                                       |
| Location    | –                            | Required                                    | ✖️               | `object`                                              |
| Boolean     | –                            | –                                           | ✖️               | `boolean`                                             |
| JSON        | –                            | –                                           | ✖️               | `object`                                              |
| Color       | –                            | Required                                    | ✖️               | `string`                                              |

#### Select Field Configuration

Fields for `select`, `radio` or `checkbox` fields can be configured in a multiline textfield.

#### **Pattern**

`label|value|option`

**1st Segment:** `label`\
The label name for the field.

**2nd Segment:** `value`\
Defines the value for the field.

{% hint style="info" %}
If no value is defined, the value will be the label name.
{% endhint %}

**3rd Segment:** `option`\
Options are optional and must be prefixed with underscore *`_`*

The following options are available:

| **Option**  | **Purpose**                                                                              |
| ----------- | ---------------------------------------------------------------------------------------- |
| `_default`  | Defines which values are selected by default. Can be used multiple times for checkboxes. |
| `_disabled` | Disables a field.                                                                        |

**Separation**

`label|value|option` must be separated by pipe: `|`

![Select field configuration example](https://1465026891-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LADWNm2iPQ4ngpcPfGc%2F-LBQH_Z0jBAqHrHa_k1m%2F-LBQI5-HPxySomVPx-8V%2FScreen%20Shot%202018-05-01%20at%2012.41.25.png?alt=media\&token=5d7ea774-98b9-4ed9-9341-23d02cf49a50)

### Main Field

The Main Field is a special attribute that can be be applied for `text`, `richtext`, `number` and `select` fields. Its main purpose is to provide a identifier for documents to help you navigating faster through lists. For example, for the Content Type `Author` you would probably choose the field `Name` to be the Main Field.

{% hint style="info" %}
A Main Field is always required. If you choose a field to be the Main Field, it will be set to be required automatically.
{% endhint %}

### Sections

Sections can be used to group a set of fields. This is useful for editors and comes handy if you need to encapsulate some fields for the REST API.

{% code title="Sections Example Document" %}

```javascript
...,
"fields": {
    "title": "Garret Ginner Pro",
    "type": "skateboard",
    "description": {
        "text": "...",
        "dimensions": "...",
        "type_of_wood": "..."
    },
    ...
},
...
```

{% endcode %}

We are planning to make sections repeatable soon. This will enable your editors to create multiple instances of a field group. A good example for this would be a band tour with multiple locations.

### Translation

To enable a field to be available for translation, just select the checkbox *Translatable* on the edit- or create field screen and save the configuration.

The translatable fields will appear in the [Writing Room](https://docs.comfortable.io/concepts-1/documents) and can be accessed by the language tabs.

## Deleting Content Types

1. Navigate to the page 'Content Types' by clicking the double-square icon in the menu bar on the left.
2. Select a content type by activating the checkbox.
3. Click the 'Trashcan'-Butto&#x6E;*.*
4. Confirm.

{% hint style="warning" %}
Deleting a `content type` **will also delete all documents** of this type!
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.comfortable.io/concepts-1/document-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
