Skip to main content

Ingredients hierarchy example

This is an example hierarchy used on the Using hierarchies page. The hierarchy of ingredients is used to tag recipes created using the recipe schema which is also included on this page.

Pre-requisites
Link copied!

See the using the content type schema examples page for details of how to choose and register these schemas from the schema examples in Dynamic Content.

How to use
Link copied!

You will need to register both the ingredients hierarchy schema and the recipe schema because the recipe schema links to content created from the ingredients hierarchy.

Ingredients list hierarchy
Link copied!

This is the ingredients hierarchy schema. Note that in the childContentTypes array in the hierarchy trait, only includes the ingredients hierarchy itself, so this is the only type of content that can be added to the hierarchy.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema-examples.com/ingredients-list",
"$comment": "Docs: https://amplience.com/docs/development/schema-examples/hierarchies/ingredients-list-hierarchy.html",
"title": "Ingredients list",
"description": "The ingredients list hierarchy used to tag recipe content",
"allOf": [
{
"$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content"
},
{
"$ref": "http://bigcontent.io/cms/schema/v2/hierarchy#/definitions/hierarchy-node"
}
],
"trait:hierarchy": {
"childContentTypes": ["https://schema-examples.com/ingredients-list"]
},
"type": "object",
"properties": {
"ingredient": {
"title": "Ingredient",
"description": "Name of ingredient",
"type": "string",
"minLength": 0,
"maxLength": 200
},
"image": {
"title": "image",
"allOf": [
{
"$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/image-link"
}
]
},
"hidden": {
"title": "hidden",
"description": "Choose to hide this ingredient",
"type": "boolean"
}
},
"propertyOrder": ["ingredient", "image"]
}

Recipe schema
Link copied!

This is the recipe schema. Content created from this schema can be tagged with items from the ingredients hierarchy. The ingredients property is an array of links to content created from the ingredients list.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema-examples.com/recipe",
"$comment": "Docs: https://amplience.com/docs/development/schema-examples/hierarchies/ingredients-list-hierarchy.html#recipe",
"title": "Recipe",
"description": "A recipe which can be tagged with ingredients from the ingredients hierarchy",
"allOf": [
{
"$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content"
}
],
"type": "object",
"properties": {
"recipeTitle": {
"title": "Recipe title",
"description": "The title of the recipe",
"type": "string",
"minLength": 0,
"maxLength": 200
},
"image": {
"title": "image",
"allOf": [
{
"$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/image-link"
}
]
},
"instructions": {
"title": "Instructions",
"description": "Cooking instructions",
"type": "string",
"format": "markdown",
"minLength": 0,
"maxLength": 2000
},
"ingredients": {
"title": "ingredients",
"type": "array",
"minItems": 0,
"maxItems": 10,
"items": {
"allOf": [
{
"$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content-link"
},
{
"properties": {
"contentType": {
"enum": ["https://schema-examples.com/ingredients-list"]
}
}
}
]
}
}
},
"propertyOrder": []
}

Content form preview
Link copied!

An example of creating a content item using a content type registered from the ingredients hierarchy example schema is shown in the image below.

The ingredients hierarchy

Using hierarchies