Content Block Schemas
Anatomy of a schema
All content block types are managed in the schemas in Publishing API.
Schemas are prefixed with content_block_*
and are picked up by Content Block Manager via the Schema
class.
When creating a new content block, we fetch all the supported schemas from Publishing API and give the user a list of
valid block types to create. Once a block type is chosen the form is then populated using all the fields within a
schema’s details
object (apart from embedded objects, more on this later), as well as the title, lead organisation
and instructions to publishers.
All fields within details
generate a standard input field by default. If a schema has an enum
type, this generates
a select field populated with the valid enum values.
Embedded objects
Schemas also support embedded objects (for example, the Pension schema
has rates embedded). If any embedded objects are included, a user has the ability to create these objects on a seperate
screen after creating the initial object. Embedded objects look like this (using rates
as an example):
"rates": {
"rate-1": {
"title": "Rate 1",
"amount": "£221.20",
"frequency": "a week",
"description": "Your weekly pension amount"
},
"rate-2": {
"title": "Rate without decimal point",
"amount": "£221",
"frequency": "a week",
"description": "Your weekly pension amount"
},
"rate-3": {
"title": "Rate with big value",
"amount": "£1,223",
"frequency": "a week",
"description": "Your weekly pension amount"
}
}
Each object has a key, which Content Block Manager automatically generates from the given title, so Rate 1
becomes rate-1
. This is immutable, so if a title changes, the key remains the same.
Currently supported schemas
There are currently 3 supported schemas in Content Block Manager: