A Structure is a predefined, custom template that determines what should populate an array or object input.
This article covers all keys available in CloudCannon for configuring your Structures. For more information, please read our documentation on Structures in general and creating a Structure.
All Structures options are configured within the _structures key at any level in the configuration cascade.
In this example, we want to populate an Array input in the blog Collection with Related Articles, including the name, description, and url fields.
cloudcannon.config.yaml
copied
cloudcannon.config.json
copied
In this example, we want to populate an Array input with Staff members, including the name, job_description, and profile_picture fields for all staff types, and the url field for Managers only.
This key defines how CloudCannon shows Structure options to populate an Object or Array input. This can be using a Select-style search bar or a pop-up modal. Modals are useful when you have several value options for your Structure.
Values can be one of the following: select, or modal.
By default, this key is select.
Show exampleHide example
In this example, the related_articles Structure only has one option so a select searchbar is appropriate.
This key defines which key within values[*].value CloudCannon should use to identify the Structure option. If CloudCannon cannot find this key in a Structure value, it will compare all other key names in the Structure value to find the correct one.
By default, this key is _type.
Show exampleHide example
In this example, we have change the id_key from the default _type to component to match our existing configuration in the content_blocks Array input.
cloudcannon.config.yaml
copied
We have configured the Array input content_blocks to use the page_components Structures.
The id_key for page_components is component.
Each option in the values array has the component key with a different value to identify that option.
cloudcannon.config.json
copied
We have configured the Array input content_blocks to use the page_components Structures.
The id_key for page_components is component.
Each option in the values array has the component key with a different value to identify that option.
This key toggles whether inputs that are not present in the Structure are visible in the Data Editor. Hiding these inputs does not delete the data. You can see structured data keys from outside a Structure by opening a file in the Source Editor. This key has no effect if remove_extra_inputs is true.
By default, this key is false (i.e, non-structure inputs are visible in the Data Editor).
Show exampleHide example
In this example, we don't want inputs outside of those listed in the Structure (e.g., old inputs from deprecated versions of this Structure) to appear in the Data Editor.
This key toggles whether CloudCannon will remove empty nested inputs from an Object or Array input that uses this Structure when you save the input configuration. CloudCannon consideres an input to be empty when its value is null, ' ', or undefined.
If this key is set to true, the id_key must be configured for this Structure, as removing inputs prevents CloudCannon from comparing Structure values. You can bring back empty inputs removed from an Object or Array input by re-adding the structure to the input.
By default, this key is false (i.e, CloudCannon does not remove empty inputs).
Show exampleHide example
In this example, we want to delete any unnecessary nested inputs (i.e., input we choose not to provide a value for) from Object or Array inputs referenceing the event_details Structure.
This key toggles whether inputs that are not present in the Structure are removed from the file before CloudCannon loads it in an editing interface. Saving the file will push this change to your Git repository.
By default, this key is false(i.e., inputs not present in the Structure are not removed from the file).
Show exampleHide example
In this example, we want to delete old inputs that are not in the Structure from the associated file.
This key toggles whether CloudCannon should treat an entry in the values array as the default option for your Object or Array input. If multiple entries in the values array are set to true, CloudCannon will use the first entry.
If CloudCannon cannot determine the type of an entry within the values array based on the id_key or matching inputs in the values.value array, it will fall back to the default entry.
By default, this key is false (i.e., the entry is not the default option).
Show exampleHide example
In this example, we want the entry labelled Employee to be our default option for populating inputs configured with the staff Structure.
This key toggles whether CloudCannon should create tabs in the Data Editor if you have two layers of nested object within your Structure.
CloudCannon would create tabs automatically for Non-unified Configuration Sites, but it must be explicitly configured in the Unified Configuration file format.
By default, this key is false (i.e., Object and Array inputs using this Structure option are not tabbed).
Show exampleHide example
In this example, we want the content and style keys in our Structure to be tabs at the top of the Data Editor, with the title and text, and color and font keys nested within those tabs respectively.
This key defines which tags are associated with a given value in a Structure. You can use tags to group and filter Structure options when selecting from a modal. The style key must be set to modal for this key to function.
This key has no default.
Show exampleHide example
In this example we have three options for the page_components Structure: Hero Component, Feature Component, and Video Component. We can search the Structure modal using the image, text, button, and video tags to filter Structure values.
This key defines which nested inputs the Structure should add to an Object or Array input. You must define this key for the Structure to function.
Nested keys can be any inputs you require in your Object or Array. For more information, please read our documentation on configuring your inputs.
This key has no default.
Show exampleHide example
In this example we want to populate the details Object input with the nested keys title, subtitle, and author we have defined under the values.value key.
This key defines the order and customing grouping for inputs within a Structure. Each groups can have a heading.
The following nested keys are available for each entry in the groups array:
heading
inputs
By default, CloudCannon respects the order of inputs as configured in the values.value key and does not include any groups.
Show exampleHide example
In this example, we want to separate the inputs into two groups with descriptive headings: title and subtitle under the Titles heading, and author under the Details heading.
This key defines the dispaly name for a given value in a Structure. The name will appear in the + Add button dropdown below an Object or Array input or in the Structures modal (if configured).
By default, this key falls back to unknown.
Show exampleHide example
In this example, we want two value options for our staff structure: one called Manager and one called Employee.
This key defines the appearance of a Card. You can configure Card preview for Structures and Snippets. This key is separate from the preview key and only affects the select and modal lists.
The following nested keys are available:
text
subtext
icon
icon_color
image
metadata
gallery
By default, CloudCannon uses the values configured for preview
Show exampleHide example
In this example, we have configured different appearance for Cards in the events array and Cards in the Structures modal used to select values for the Array input.
Structures now support the new preview option. Read our migration guide if you are still using the old options: text_key, subtext_key, image_key, preview_image, icon, image, description, and image_size.