Skip to content

Sections and EntryTypes

Ian DeRanieri edited this page Feb 9, 2018 · 5 revisions

Sections

Craft has three native entryTypes: Singles, Channels, and Structures. The Architect considers Channel and Structures to be the same thing, since conceptually Structures are just hierarchical channels.

The sections object is an array of Section objects.

"sections": [

]

Singles

{
  "name": "",
  "handle": "",
  "type": "single",
  "enableVersioning": ,
  "siteSettings": [
    {
      "hasUrls": ,
      "uriFormat": "",
      "template": ""
    },
    {
      "siteId": "",
      "hasUrls": ,
      "uriFormat": "",
      "template": ""
    }
  ]
}
Attribute Accepts Notes
name String The name of this Section.
handle String The handle of this Section. This is usually a camelCased version of the name, but this isn't required.
type String For Singles, use single
enableVersioning Boolean Does this section save versions?
hasUrls Boolean Does this section have public urls?
uriFormat String The format of the urls. If this single is the homepage, use __home__.
template String The path to the template file this Section will use. This is scoped to the main templates directory, so paths should be relative to that directory.

Note the repeated siteSettings attributes for each Site. Without the ID, the Section will be mapped to the primary site. You can specify and add this Section to multiple sites by repeating the object within the siteSettings array and adding a siteId attribute with the handle of the appropriate Site.

Channels and Structures

{
  "name": "",
  "handle": "",
  "type": "channel",
  "enableVersioning": ,
  "maxLevels": ,
  "siteSettings": [
    {
      "hasUrls": ,
      "uriFormat": "",
      "template": "",
      "enabledByDefault":
    },
    {
      "siteId": "",
      "hasUrls": ,
      "uriFormat": "",
      "template": "",
      "enabledByDefault":
    }
  ]
}
Attribute Accepts Notes
name String The name of this Section.
handle String The handle of this Section. This is usually a camelCased version of the name, but this isn't required.
type String Select channel or structure.
enableVersioning Boolean Does this section save versions?
maxLevels Number For Structures only. Note the number of levels this Structure should be limited to.
hasUrls Boolean Does this section have public urls?
uriFormat String The format of the urls.
template String The path to the template file this Section will use. This is scoped to the main templates directory, so paths should be relative to that directory.
enabledByDefault Boolean Are the entries added to this Section enabled by default?

Note the repeated siteSettings attributes for each Site. Without the ID, the Section will be mapped to the primary site. You can specify and add this Section to multiple sites by repeating the object within the siteSettings array and adding a siteId attribute with the handle of the appropriate Site.

EntryTypes

The entryTypes object is an array of EntryType objects.

"entryTypes": [

]

Singles

{
  "sectionHandle": "",
  "hasTitleField": ,
  "titleLabel": "",
  "titleFormat": "",
  "fieldLayout": {

  },
  "requiredFields": [

  ]
}
Attribute Accepts Notes
sectionHandle String The handle of the Section that this entryType belongs to.
hasTitleField Boolean Must be true or false. If true, complete the titleLabel field. If false, complete the titleFormat field. Whichever option you use, complete the other one with null to ensure no errors on import.
titleLabel String If hasTitleField is true, this will be the label for the Title field that the user can enter.
titleFormat String If hasTitleField is false, this will be the value of the Title Format field.
fieldLayout Arrays Each array corresponds to a tab created on the field layout. Within each array, list the handles of the fields that will go in each tab.
requiredFields Array An array of handles, each one denoting a field that will be made required upon import.

Channels and Structures

{
  "sectionHandle": "",
  "hasTitleField": ,
  "titleLabel": "",
  "titleFormat": "",
  "name": "",
  "handle": "",
  "fieldLayout": {

  },
  "requiredFields": [

  ]
}
Attribute Accepts Notes
sectionHandle String The handle of the Section that this entryType belongs to.
hasTitleField Boolean Must be true or false. If true, complete the titleLabel field. If false, complete the titleFormat field. Whichever option you use, complete the other one with null to ensure no errors on import.
titleLabel String If hasTitleField is true, this will be the label for the Title field that the user can enter.
titleFormat String If hasTitleField is false, this will be the value of the Title Format field.
name String The name of this entryType.
handle String The handle of this entryType. This is usually a camelCased version of the name, but this isn't required.
fieldLayout Arrays Each array corresponds to a tab created on the field layout. Within each array, list the handles of the fields that will go in each tab.
requiredFields Array An array of handles, each one denoting a field that will be made required upon import.