Folders provide a structure to your assets in the CI HUB panel. 

Introduction

censhare does not have a hierarchical asset structure. Assets are structured via asset relations. On the other side, the CI HUB panel displays assets in a tree-like folder structure. The folder object of the schemas provides a mapping that connects both data models:

  • Static pages are used as root folders. If a user opens the censhare integration in the CI HUB panel, all existing static pages are shown as root folders.
  • Group assets are represented as folders. If a user clicks on a root folder, the CI HUB panel shows all assigned Group assets. So, the assigned group asset form the first child level in the CI HUB folder tree. Group assets with other assigned group assets are shown as nested folders.
  • Media assets that are are assigned to a static page or a group asset, are represented as files inside the respective folder that represents the static page or group.

Since the censhare data model is based on relations and not a physical file structure, there are some particularities:

  • Groups can be assigned in both directions (child/parent). In the CI HUB, the folder structure is always built from the static page as root folder.
  • A group can be assigned to multiple other groups. In the CI HUB panel, this group displays multiple times as sub-folder of the folders that represent the assigned groups. 
  • An asset can be assigned to multiple groups. In the CI HUB panel, this asset is represented multiple times inside the respective folders.

Folder schema

Folders are defined in the folder-schema.json. The folder schema  basic properties, for example the name and two relation properties. There is one for parent relations:

Example
"parentFolders": {
  "type": "array",
  "items": {
    "cs:relation.direction": "parent",
    "oneOf": [
      {
        "type": "string"
      },
      {
        "type": "null"
      }
    ],
    "cs:relation.$ref_type": "link",
    cs:relation.key": "user.cihub-folder."
  }
}

And there is one for the child relations:

Example
"subfolders": {
  "type": "array",
  "items": {
    "cs:relation.direction": "child",
    "oneOf": [
      {
        "type": "string"
      },
      {
        "type": "null"
      }
    ],
    "cs:relation.$ref_type": "link",
    "cs:relation.key": "user.cihub-folder."
  }
}

Link to a folder in an entity

Each entity definition needs a property that allows to store a link to a parent folder. The link is mapped to an asset feature reference. As there can be links to several folders, the type of parentFolders property is defined as array, for example:

Example
"parentFolders": {
   "type": "array",
   "items": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "cs:feature.key": "demo:feature-asset-reference",
      "cs:feature.$ref_type": "link",
      "type": "string",
      "pattern": ".*/folder/.*"
}

By default, this definition is already stored in the media-schema.json and included into other entity. If you include media-schema.json as mixin into an entity definition it is already there. For more information, see Composite schemas.

Note that the links between various folders or static pages are defined as relations between asset. In opposite, the links from assets to folders are defined as asset feature references. Using an asset references, has technical reasons for performance exspcially when there are links by many media assets to a folder.