Skip to content

Multiple defaults for content type #335

@jimafisk

Description

@jimafisk

In the Plenti CMS, we know to apply schema (defines field widgets) from _schema.json to content when its key structure exactly matches that of _defaults.json for corresponding content type.

However, if you ever want to change the structure of a content type (add/remove fields, or change the name of an existing field), you need to update every instance of content of that type in order for the schema to continue to get applied correctly. If you have a lot of content, this would likely require an automated content migration. It would be nice if you could just define the new structure in _defaults.json and allow the old structure to still apply to content that was created previously.

Another typical scenario is sometimes you might want optional fields on a content type (like an icon in a table header, or a secondary button in a widget), but you don't always necessarily want this in all instances, but you still want schema to work in either case. The challenge here would be that you might need a switcher when creating new content to determine which defaults to use.

A typical _defaults.json file currently might look something like this:

{
    "id": "",
    "title": "Event title",
    "date": "1/1/2024",
    "body": "Event description"
}

But it would be nice if you could wrap it in an array and Plenti would match content against any of the definitions in the array, something like:

[
{
    "id": "",
    "title": "Event title",
    "date": "1/1/2024",
    "body": "Event description"
},
{
    "id": "",
    "title": "Event title",
    "date": "1/1/2024",
    "body": "Event description",
   "new_field": "New field value"
}
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions